Keep the user store in the shared process.

This commit is contained in:
joshaber 2016-06-24 17:28:50 -04:00
parent d6b6b298f4
commit 3619a49c60
4 changed files with 12 additions and 2 deletions

View file

@ -1,11 +1,16 @@
import {ipcRenderer, remote} from 'electron'
import {Message} from './message'
import tokenStore from './token-store'
import UsersStore from './users-store'
const {BrowserWindow} = remote
type SharedProcessFunction = (args: any) => Promise<any>
const registeredFunctions: {[key: string]: SharedProcessFunction} = {}
const usersStore = new UsersStore(localStorage, tokenStore)
usersStore.loadFromStore()
register('console/log', ({args}: {args: any[]}) => {
console.log('', ...args)
return Promise.resolve()
@ -20,6 +25,11 @@ register('ping', () => {
return Promise.resolve('pong')
})
register('users/get', () => {
// TODO: Not quite right. Gotta go to JSON.
return Promise.resolve(usersStore.getUsers())
})
ipcRenderer.on('shared/request', (event, args) => {
dispatch(args[0])
})

View file

@ -1,8 +1,8 @@
import {Emitter, Disposable} from 'event-kit'
import {DataStore, SecureStore} from './stores'
import {getKeyForUser} from './auth'
import User from './user'
import {getKeyForUser} from '../auth'
import User from '../user'
export default class UsersStore {
private dataStore: DataStore