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

Commit

Permalink
watch RVS rtaher than dispatcher for room changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ara4n committed Mar 21, 2022
1 parent 6347b88 commit 6234d71
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/stores/right-panel/RightPanelStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import defaultDispatcher from '../../dispatcher/dispatcher';
import { pendingVerificationRequestForUser } from '../../verification';
import SettingsStore from "../../settings/SettingsStore";
import { RightPanelPhases } from "./RightPanelStorePhases";
import { ActionPayload } from "../../dispatcher/payloads";
import { Action } from "../../dispatcher/actions";
import { SettingLevel } from "../../settings/SettingLevel";
import { UPDATE_EVENT } from '../AsyncStore';
Expand Down Expand Up @@ -380,9 +379,25 @@ export default class RightPanelStore extends ReadyWatchingStore {

private onRoomViewStoreUpdate = () => {
// TODO: only use this function instead of the onDispatch (the whole onDispatch can get removed!) as soon groups are removed
const oldRoomId = this.viewedRoomId;
this.viewedRoomId = RoomViewStore.getRoomId();
// load values from byRoomCache with the viewedRoomId.
this.loadCacheFromSettings();

// if we're switching to a room, clear out any stale MemberInfo cards
// in order to fix https://github.com/vector-im/element-web/issues/21487
if (oldRoomId !== this.viewedRoomId) {
if (this.currentCard?.phase !== RightPanelPhases.EncryptionPanel) {
const panel = this.byRoom[this.viewedRoomId];
if (panel?.history) {
panel.history = panel.history.filter(
(card) => card.phase != RightPanelPhases.RoomMemberInfo &&
card.phase != RightPanelPhases.Room3pidMemberInfo,
);
}
}
}

// If the right panel stays open mode is used, and the panel was either
// closed or never shown for that room, then force it open and display
// the room member list.
Expand Down Expand Up @@ -435,20 +450,6 @@ export default class RightPanelStore extends ReadyWatchingStore {
}
break;
}
case Action.ViewRoom: {
// if we're switching to a room, clear out any stale MemberInfo cards
// in order to fix https://github.com/vector-im/element-web/issues/21487
if (payload.room_id && this.currentCard?.phase !== RightPanelPhases.EncryptionPanel) {
const panel = this.byRoom[payload.room_id];
if (panel?.history) {
panel.history = panel.history.filter(
(card) => card.phase != RightPanelPhases.RoomMemberInfo &&
card.phase != RightPanelPhases.Room3pidMemberInfo,
);
}
}
break;
}
}
};

Expand Down

0 comments on commit 6234d71

Please sign in to comment.