Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
riqo
8203a90de5 add initial state shape 2021-06-09 09:03:52 -05:00

View file

@ -1,16 +1,51 @@
const Store = require('electron-store'); const Store = require('electron-store');
const schema = { const schema = {
// should be separate, used to authenticate against business and platform
key: { key: {
type: 'string', type: 'string',
}, },
crimataId: {
type: 'string' profile: {
} type:
},
messages: {
new: Message[],
saved: ViewMessages[]
},
}; };
export const store = new Store({ export const store = new Store({
schema, schema,
encryptionKey: "super user test" 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
}