Reset space contexts as some users may have loops stuck in their local storage
This commit is contained in:
parent
b64b956aa4
commit
28fa1cb44c
1 changed files with 3 additions and 7 deletions
|
@ -51,11 +51,7 @@ export const UPDATE_SELECTED_SPACE = Symbol("selected-space");
|
||||||
|
|
||||||
const MAX_SUGGESTED_ROOMS = 20;
|
const MAX_SUGGESTED_ROOMS = 20;
|
||||||
|
|
||||||
const getLastViewedRoomsStorageKey = (space?: Room) => {
|
const getSpaceContextKey = (space?: Room) => `mx_space_context_${space?.roomId || "home_space"}`;
|
||||||
const lastViewRooms = "mx_last_viewed_rooms";
|
|
||||||
const homeSpace = "home_space";
|
|
||||||
return `${lastViewRooms}_${space?.roomId || homeSpace}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const partitionSpacesAndRooms = (arr: Room[]): [Room[], Room[]] => { // [spaces, rooms]
|
const partitionSpacesAndRooms = (arr: Room[]): [Room[], Room[]] => { // [spaces, rooms]
|
||||||
return arr.reduce((result, room: Room) => {
|
return arr.reduce((result, room: Room) => {
|
||||||
|
@ -119,7 +115,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
|
|
||||||
if (contextSwitch) {
|
if (contextSwitch) {
|
||||||
// view last selected room from space
|
// view last selected room from space
|
||||||
const roomId = window.localStorage.getItem(getLastViewedRoomsStorageKey(this.activeSpace));
|
const roomId = window.localStorage.getItem(getSpaceContextKey(this.activeSpace));
|
||||||
|
|
||||||
if (roomId && this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join") {
|
if (roomId && this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join") {
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
|
@ -542,7 +538,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
// Persist last viewed room from a space
|
// Persist last viewed room from a space
|
||||||
// we don't await setActiveSpace above as we only care about this.activeSpace being up to date
|
// we don't await setActiveSpace above as we only care about this.activeSpace being up to date
|
||||||
// synchronously for the below code - everything else can and should be async.
|
// synchronously for the below code - everything else can and should be async.
|
||||||
window.localStorage.setItem(getLastViewedRoomsStorageKey(this.activeSpace), payload.room_id);
|
window.localStorage.setItem(getSpaceContextKey(this.activeSpace), payload.room_id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "after_leave_room":
|
case "after_leave_room":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue