diff --git a/src/composables/store.ts b/src/composables/store.ts index 16f8409..a74d209 100644 --- a/src/composables/store.ts +++ b/src/composables/store.ts @@ -1,16 +1,51 @@ const Store = require('electron-store'); + const schema = { + // should be separate, used to authenticate against business and platform key: { type: 'string', }, - crimataId: { - type: 'string' - } + + profile: { + type: + }, + + messages: { + new: Message[], + saved: ViewMessages[] + }, + }; export const store = new Store({ schema, encryptionKey: "super user test" }); + + +export const emitInitialState = () => { + + const profile = store.get(profile); + const messages = store.get(messages); + + emit("initial-state", { + messages, + profile + }); +} + + +/* add a message to state.messages */ + +export function addMessage(message: Message) { + + // update state + // TODO: add logic to handle new vs saved + state.messages.new.push(message); + state.messages.saved.push(message); + + saveState(); + // emit new message +}