From 58a4cca09950be8875a078058a2b761838b29138 Mon Sep 17 00:00:00 2001 From: Timo K Date: Fri, 14 Jan 2022 15:00:46 +0100 Subject: [PATCH 1/3] always show right panel after setting a card - if the desired behaviour is to only update the panel without showin, hide needs to be called after setCard/s --- src/stores/right-panel/RightPanelStore.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index b714263e70c..2424aeb9c13 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -140,6 +140,7 @@ export default class RightPanelStore extends ReadyWatchingStore { // This function behaves as following: // Update state: if the same phase is send but with a state // Set right panel and erase history: if a "different to the current" phase is send (with or without a state) + // If the right panel is set, this function also shows the right panel. const redirect = this.getVerificationRedirect(card); const targetPhase = redirect?.phase ?? card.phase; const cardState = redirect?.state ?? (Object.keys(card.state ?? {}).length === 0 ? null : card.state); @@ -157,14 +158,17 @@ export default class RightPanelStore extends ReadyWatchingStore { if (targetPhase !== this.currentCard?.phase) { // Set right panel and erase history. + this.show(); this.setRightPanelCache({ phase: targetPhase, state: cardState ?? {} }, rId); } } public setCards(cards: IRightPanelCard[], allowClose = true, roomId: string = null) { + // This function sets the history of the right panel and shows the right panel if not already visible. const rId = roomId ?? this.viewedRoomId; const history = cards.map(c => ({ phase: c.phase, state: c.state ?? {} })); this.byRoom[rId] = { history, isOpen: true }; + this.show(); this.emitAndUpdateSettings(); } @@ -173,6 +177,7 @@ export default class RightPanelStore extends ReadyWatchingStore { allowClose = true, roomId: string = null, ) { + // This function appends a card to the history and shows the right panel (if now already visible) const rId = roomId ?? this.viewedRoomId; const redirect = this.getVerificationRedirect(card); const targetPhase = redirect?.phase ?? card.phase; @@ -194,7 +199,7 @@ export default class RightPanelStore extends ReadyWatchingStore { isOpen: !allowClose, }; } - + this.show(); this.emitAndUpdateSettings(); } @@ -215,6 +220,18 @@ export default class RightPanelStore extends ReadyWatchingStore { this.emitAndUpdateSettings(); } + public show() { + if (!this.isOpenForRoom) { + this.togglePanel(); + } + } + + public hide() { + if (this.isOpenForRoom) { + this.togglePanel(); + } + } + // Private private loadCacheFromSettings() { const room = this.mxClient?.getRoom(this.viewedRoomId); From ef35c0afba459f1561c5da2476c00d92c00d7696 Mon Sep 17 00:00:00 2001 From: Timo K Date: Fri, 14 Jan 2022 15:04:02 +0100 Subject: [PATCH 2/3] comment consistency --- src/stores/right-panel/RightPanelStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index 2424aeb9c13..0e003061921 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -177,7 +177,7 @@ export default class RightPanelStore extends ReadyWatchingStore { allowClose = true, roomId: string = null, ) { - // This function appends a card to the history and shows the right panel (if now already visible) + // This function appends a card to the history and shows the right panel if now already visible. const rId = roomId ?? this.viewedRoomId; const redirect = this.getVerificationRedirect(card); const targetPhase = redirect?.phase ?? card.phase; From 25483decbc01252af591f84cc0efdd8fbcff8723 Mon Sep 17 00:00:00 2001 From: Timo K Date: Fri, 14 Jan 2022 15:09:27 +0100 Subject: [PATCH 3/3] case does not always get reached --- src/stores/right-panel/RightPanelStore.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index 0e003061921..9f6903d3572 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -154,12 +154,13 @@ export default class RightPanelStore extends ReadyWatchingStore { hist[hist.length - 1].state = cardState; this.emitAndUpdateSettings(); return; - } - - if (targetPhase !== this.currentCard?.phase) { + } else if (targetPhase !== this.currentCard?.phase) { // Set right panel and erase history. this.show(); this.setRightPanelCache({ phase: targetPhase, state: cardState ?? {} }, rId); + } else { + this.show(); + this.emitAndUpdateSettings(); } }