add initial state shape
This commit is contained in:
parent
3b5da6124f
commit
8203a90de5
1 changed files with 38 additions and 3 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue