Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Reset store state when logging out #930

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/stores/LifecycleStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class LifecycleStore extends Store {
});
dis.dispatch(deferredAction);
break;
case 'on_logged_out':
this._state = {
deferred_action: null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this duplication feels pretty ming and fragile, surely we should use the same pattern as RoomViewStore and have an INITIAL_STATE variable which gets copied over the top of this._state.

};
break;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/stores/RoomViewStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class RoomViewStore extends Store {
case 'join_room':
this._joinRoom(payload);
break;
case 'on_logged_out':
this.reset();
break;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/stores/SessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class SessionStore extends Store {
cachedPassword: null,
});
break;
case 'on_logged_out':
this._state = {
cachedPassword: null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this duplication feels pretty ming and fragile, surely we should use the same pattern as RoomViewStore and have an INITIAL_STATE variable which gets copied over the top of this._state.

};
break;
}
}

Expand Down