mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 17:11:55 +00:00
fix(mobx): properly persist login state
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user