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

Commit 8cd805a

Browse files
authored
Don't restore MemberInfo from RightPanel history when viewing a room (#8090)
As bringing up a specific MemberInfo when you view a room is freaky, even if it happened to be the last thing you were doing in that room. Fixes element-hq/element-web#21487
1 parent dd53b22 commit 8cd805a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/stores/right-panel/RightPanelStore.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
159159
if (!this.isPhaseValid(targetPhase)) return;
160160

161161
if ((targetPhase === this.currentCardForRoom(rId)?.phase && !!cardState)) {
162-
// Update state: set right panel with a new state but keep the phase (dont know it this is ever needed...)
162+
// Update state: set right panel with a new state but keep the phase (don't know it this is ever needed...)
163163
const hist = this.byRoom[rId]?.history ?? [];
164164
hist[hist.length - 1].state = cardState;
165165
this.emitAndUpdateSettings();
@@ -367,6 +367,7 @@ export default class RightPanelStore extends ReadyWatchingStore {
367367
}
368368

369369
private onVerificationRequestUpdate = () => {
370+
if (!this.currentCard?.state) return;
370371
const { member } = this.currentCard.state;
371372
if (!member) return;
372373
const pendingRequest = pendingVerificationRequestForUser(member);
@@ -378,9 +379,25 @@ export default class RightPanelStore extends ReadyWatchingStore {
378379

379380
private onRoomViewStoreUpdate = () => {
380381
// TODO: only use this function instead of the onDispatch (the whole onDispatch can get removed!) as soon groups are removed
382+
const oldRoomId = this.viewedRoomId;
381383
this.viewedRoomId = RoomViewStore.getRoomId();
382384
// load values from byRoomCache with the viewedRoomId.
383385
this.loadCacheFromSettings();
386+
387+
// if we're switching to a room, clear out any stale MemberInfo cards
388+
// in order to fix https://github.com/vector-im/element-web/issues/21487
389+
if (oldRoomId !== this.viewedRoomId) {
390+
if (this.currentCard?.phase !== RightPanelPhases.EncryptionPanel) {
391+
const panel = this.byRoom[this.viewedRoomId];
392+
if (panel?.history) {
393+
panel.history = panel.history.filter(
394+
(card) => card.phase != RightPanelPhases.RoomMemberInfo &&
395+
card.phase != RightPanelPhases.Room3pidMemberInfo,
396+
);
397+
}
398+
}
399+
}
400+
384401
// If the right panel stays open mode is used, and the panel was either
385402
// closed or never shown for that room, then force it open and display
386403
// the room member list.

0 commit comments

Comments
 (0)