fix(mobx): properly persist login state

This commit is contained in:
Paul
2021-12-24 12:00:24 +00:00
parent ef1ddb7771
commit 189d0b5ff9
5 changed files with 12 additions and 4 deletions

View File

@@ -112,7 +112,7 @@ export default class State {
* Register reaction listeners for persistent data stores.
* @returns Function to dispose of listeners
*/
registerListeners(client: Client) {
registerListeners(client?: Client) {
const listeners = this.persistent.map(([id, store]) => {
return reaction(
() => stringify(store.toJSON()),
@@ -120,6 +120,7 @@ export default class State {
try {
await localforage.setItem(id, JSON.parse(value));
if (id === "sync") return;
if (!client) return;
const revision = +new Date();
switch (id) {

View File

@@ -85,6 +85,7 @@ export default class Auth implements Store, Persistent<Data> {
@action setSession(session: Session) {
this.sessions.set(session.user_id, { session });
this.current = session.user_id;
console.log(this.sessions, this.current);
}
/**