diff --git a/src/TextForEvent.tsx b/src/TextForEvent.tsx index 398b3568cf1..0895f9378e0 100644 --- a/src/TextForEvent.tsx +++ b/src/TextForEvent.tsx @@ -504,11 +504,6 @@ const onPinnedOrUnpinnedMessageClick = (messageId: string, roomId: string): void const onPinnedMessagesClick = (): void => { RightPanelStore.instance.setRightPanel(RightPanelPhases.PinnedMessages, null, false); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.PinnedMessages, - // allowClose: false, - // }); }; function textForPinnedEvent(event: MatrixEvent, allowJSX: boolean): () => string | JSX.Element | null { diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 637a8cc4a4e..361d9334948 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -824,10 +824,6 @@ export default class GroupView extends React.Component { _onAdminsLinkClick = () => { RightPanelStore.instance.setRightPanel(RightPanelPhases.GroupMemberList); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.GroupMemberList, - // }); }; _getGroupSection() { diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index e4e827100c2..a2cbf70052a 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -331,10 +331,6 @@ export class RoomView extends React.Component { if (WidgetLayoutStore.instance.hasMaximisedWidget(this.state.room)) { // Show chat in right panel when a widget is maximised RightPanelStore.instance.setRightPanel(RightPanelPhases.Timeline); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.Timeline, - // }); } this.checkWidgets(this.state.room); // this.checkRightPanel(this.state.room); diff --git a/src/components/structures/SpaceRoomView.tsx b/src/components/structures/SpaceRoomView.tsx index 0ddc5a03576..5400ae5d07b 100644 --- a/src/components/structures/SpaceRoomView.tsx +++ b/src/components/structures/SpaceRoomView.tsx @@ -165,12 +165,6 @@ const SpaceInfo = ({ space }: { space: Room }) => { className="mx_SpaceRoomView_info_memberCount" onClick={() => { RightPanelStore.instance.setRightPanel(RightPanelPhases.RoomMemberList, { space } ); - - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomMemberList, - // refireParams: { space }, - // }); }} > { _t("%(count)s members", { count }) } @@ -476,11 +470,6 @@ const SpaceLanding = ({ space }: { space: Room }) => { const onMembersClick = () => { RightPanelStore.instance.setRightPanel(RightPanelPhases.RoomMemberList, { space } ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomMemberList, - // refireParams: { space }, - // }); }; return
@@ -855,37 +844,16 @@ export default class SpaceRoomView extends React.PureComponent { RightPanelPhases.SpaceMemberInfo, { space: this.props.space, member: payload.member }, ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.SpaceMemberInfo, - // refireParams: { - // space: this.props.space, - // member: payload.member, - // }, - // }); } else if (payload.action === "view_3pid_invite" && payload.event) { RightPanelStore.instance.setRightPanel( RightPanelPhases.Space3pidMemberInfo, { space: this.props.space, member: payload.member }, ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.Space3pidMemberInfo, - // refireParams: { - // space: this.props.space, - // event: payload.event, - // }, - // }); } else { RightPanelStore.instance.setRightPanel( RightPanelPhases.SpaceMemberList, { space: this.props.space }, ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.SpaceMemberList, - // refireParams: { space: this.props.space }, - // }); } }; diff --git a/src/components/structures/ThreadView.tsx b/src/components/structures/ThreadView.tsx index ffc65c97970..809594965a8 100644 --- a/src/components/structures/ThreadView.tsx +++ b/src/components/structures/ThreadView.tsx @@ -94,10 +94,6 @@ export default class ThreadView extends React.Component { if (prevProps.room !== this.props.room) { RightPanelStore.instance.setRightPanel( RightPanelPhases.RoomSummary ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomSummary, - // }); } } @@ -206,7 +202,7 @@ export default class ThreadView extends React.Component { event_id: this.state.thread?.id, }; - let previousPhase = RightPanelStore.instance.previousRoom.phase; + let previousPhase = RightPanelStore.instance.previousPanel.phase; if (!SettingsStore.getValue("feature_maximised_widgets")) { previousPhase = RightPanelPhases.ThreadPanel; } diff --git a/src/components/views/context_menus/RoomContextMenu.tsx b/src/components/views/context_menus/RoomContextMenu.tsx index a9b69cd8b4e..e783f14bc2b 100644 --- a/src/components/views/context_menus/RoomContextMenu.tsx +++ b/src/components/views/context_menus/RoomContextMenu.tsx @@ -248,11 +248,6 @@ const RoomContextMenu = ({ room, onFinished, ...props }: IProps) => { ensureViewingRoom(); RightPanelStore.instance.setRightPanel( RightPanelPhases.RoomSummary, null, false ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomSummary, - // allowClose: false, - // }); onFinished(); }} label={_t("Widgets")} diff --git a/src/components/views/elements/MemberEventListSummary.tsx b/src/components/views/elements/MemberEventListSummary.tsx index 55a994e6f77..10d44f0954c 100644 --- a/src/components/views/elements/MemberEventListSummary.tsx +++ b/src/components/views/elements/MemberEventListSummary.tsx @@ -33,11 +33,6 @@ import RightPanelStore from '../../../stores/right-panel/RightPanelStore'; const onPinnedMessagesClick = (): void => { RightPanelStore.instance.setRightPanel( RightPanelPhases.PinnedMessages, null, false ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.PinnedMessages, - // allowClose: false, - // }); }; const SENDER_AS_DISPLAY_NAME_EVENTS = [EventType.RoomServerAcl, EventType.RoomPinnedEvents]; diff --git a/src/components/views/groups/GroupMemberList.js b/src/components/views/groups/GroupMemberList.js index 82aaeb0541c..03da84c7577 100644 --- a/src/components/views/groups/GroupMemberList.js +++ b/src/components/views/groups/GroupMemberList.js @@ -171,11 +171,6 @@ export default class GroupMemberList extends React.Component { RightPanelPhases.GroupMemberList, { groupId: this.props.groupId }, ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.GroupMemberList, - // refireParams: { groupId: this.props.groupId }, - // }); }); }; diff --git a/src/components/views/messages/MKeyVerificationRequest.tsx b/src/components/views/messages/MKeyVerificationRequest.tsx index f10e22657f2..5020f0bbd46 100644 --- a/src/components/views/messages/MKeyVerificationRequest.tsx +++ b/src/components/views/messages/MKeyVerificationRequest.tsx @@ -52,11 +52,6 @@ export default class MKeyVerificationRequest extends React.Component { const { verificationRequest } = this.props.mxEvent; const member = MatrixClientPeg.get().getUser(verificationRequest.otherUserId); RightPanelStore.instance.setRightPanel(RightPanelPhases.EncryptionPanel, { verificationRequest, member } ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.EncryptionPanel, - // refireParams: { verificationRequest, member }, - // }); }; private onRequestChanged = () => { diff --git a/src/components/views/right_panel/BaseCard.tsx b/src/components/views/right_panel/BaseCard.tsx index 13447ef50fe..4949123b057 100644 --- a/src/components/views/right_panel/BaseCard.tsx +++ b/src/components/views/right_panel/BaseCard.tsx @@ -67,11 +67,6 @@ const BaseCard: React.FC = ({ // RightPanelStore.instance.popRightPanel(); RightPanelStore.instance.setRightPanel(previousPhase, refireParams ); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: previousPhase, - // refireParams: refireParams, - // }); }; const label = previousPhaseLabel ?? _t("Back"); backButton = ; diff --git a/src/components/views/right_panel/EncryptionPanel.tsx b/src/components/views/right_panel/EncryptionPanel.tsx index 6bb7edb9059..8998efad049 100644 --- a/src/components/views/right_panel/EncryptionPanel.tsx +++ b/src/components/views/right_panel/EncryptionPanel.tsx @@ -117,11 +117,6 @@ const EncryptionPanel: React.FC = (props: IProps) => { RightPanelPhases.EncryptionPanel, { member, verificationRequest: verificationRequest_ }, ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.EncryptionPanel, - // refireParams: { member, verificationRequest: verificationRequest_ }, - // }); }, [member]); const requested = diff --git a/src/components/views/right_panel/HeaderButtons.tsx b/src/components/views/right_panel/HeaderButtons.tsx index e693c1810c3..98ce3ae8451 100644 --- a/src/components/views/right_panel/HeaderButtons.tsx +++ b/src/components/views/right_panel/HeaderButtons.tsx @@ -67,11 +67,6 @@ export default abstract class HeaderButtons

extends React.Component) { RightPanelStore.instance.setRightPanel(phase, extras); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: phase, - // refireParams: extras, - // }); } public isPhase(phases: string | string[]) { diff --git a/src/components/views/right_panel/RoomSummaryCard.tsx b/src/components/views/right_panel/RoomSummaryCard.tsx index 68f1262c367..a0a3d3f98cb 100644 --- a/src/components/views/right_panel/RoomSummaryCard.tsx +++ b/src/components/views/right_panel/RoomSummaryCard.tsx @@ -99,13 +99,6 @@ const AppRow: React.FC = ({ app, room }) => { const onOpenWidgetClick = () => { // TODO RightPanelPhase: should push the widget RightPanelStore.instance.setRightPanel(RightPanelPhases.Widget, { widgetId: app.id }); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.Widget, - // refireParams: { - // widgetId: app.id, - // }, - // }); }; const isPinned = WidgetLayoutStore.instance.isInContainer(room, app, Container.Top); @@ -235,21 +228,11 @@ const AppsSection: React.FC = ({ room }) => { export const onRoomMembersClick = (allowClose = true) => { // TODO RightPanelStore: should push the phase RightPanelStore.instance.setRightPanel(RightPanelPhases.RoomMemberList, undefined, allowClose); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomMemberList, - // allowClose, - // }); }; export const onRoomFilesClick = (allowClose = true) => { // TODO RightPanelStore: should push the phase RightPanelStore.instance.setRightPanel(RightPanelPhases.FilePanel, undefined, allowClose); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.FilePanel, - // allowClose, - // }); }; const onRoomSettingsClick = () => { diff --git a/src/components/views/right_panel/UserInfo.tsx b/src/components/views/right_panel/UserInfo.tsx index 6e0ef62b776..f9651e8bc98 100644 --- a/src/components/views/right_panel/UserInfo.tsx +++ b/src/components/views/right_panel/UserInfo.tsx @@ -1660,11 +1660,6 @@ const UserInfo: React.FC = ({ const onEncryptionPanelClose = () => { // TODO RightPanelStore: here we want to pop the panel RightPanelStore.instance.setRightPanel(previousPhase, refireParams); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: previousPhase, - // refireParams: refireParams, - // }); }; let content; diff --git a/src/components/views/right_panel/WidgetCard.tsx b/src/components/views/right_panel/WidgetCard.tsx index 6d1e79f7f37..37f4750239d 100644 --- a/src/components/views/right_panel/WidgetCard.tsx +++ b/src/components/views/right_panel/WidgetCard.tsx @@ -51,10 +51,6 @@ const WidgetCard: React.FC = ({ room, widgetId, onClose }) => { //TODO RightPanelStore: here we want to just pop the widget card. RightPanelStore.instance.setRightPanel(RightPanelPhases.RoomSummary); - // defaultDispatcher.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.RoomSummary, - // }); } }, [app, isPinned]); diff --git a/src/components/views/rooms/RoomListHeader.tsx b/src/components/views/rooms/RoomListHeader.tsx index 18c4fce36a0..e8b069972ca 100644 --- a/src/components/views/rooms/RoomListHeader.tsx +++ b/src/components/views/rooms/RoomListHeader.tsx @@ -101,7 +101,6 @@ const PrototypeCommunityContextMenu = (props) => { room_id: chat.roomId, }, true); RightPanelStore.instance.setRightPanel(RightPanelPhases.RoomMemberList, undefined, undefined, chat.roomId); - // dis.dispatch({ action: Action.SetRightPanelPhase, phase: RightPanelPhases.RoomMemberList }); } else { // "This should never happen" clauses go here for the prototype. Modal.createTrackedDialog('Failed to find general chat', '', ErrorDialog, { diff --git a/src/stores/right-panel/RightPanelStore.ts b/src/stores/right-panel/RightPanelStore.ts index aea2dce6400..32e0d1f5712 100644 --- a/src/stores/right-panel/RightPanelStore.ts +++ b/src/stores/right-panel/RightPanelStore.ts @@ -38,19 +38,6 @@ interface IPhaseAndState { state: IPanelState; } -// const INITIAL_STATE: IState = { -// panelHistory: [], -// currentPanel: null, -// previousPanel: null, -// isOpen: null, -// // byRoom: {}, -// // byGroup: {}, -// // showGroupPanel: SettingsStore.getValue("showRightPanelInGroup"), -// // lastRoomPhase: SettingsStore.getValue("lastRightPanelPhaseForRoom"), -// // lastGroupPhase: SettingsStore.getValue("lastRightPanelPhaseForGroup"), -// // lastRoomPhaseParams: {}, -// }; - const GROUP_PHASES = [ RightPanelPhases.GroupMemberList, RightPanelPhases.GroupRoomList, @@ -66,7 +53,12 @@ const MEMBER_INFO_PHASES = [ /** * A class for tracking the state of the right panel between layouts and - * sessions. + * sessions. This state includes a history for each room. Each history element contains + * the phase (e.g. RoomMemberInfo) and the state (e.g. the member) associated with it. + * + * Groups are treated the same then rooms (They are also stored in the byRoom object). + * This is possible since the store keeps track of the opened room/group -> the store will + * provide the correct history for that group/room. */ export default class RightPanelStore extends ReadyWatchingStore { private static internalInstance: RightPanelStore; @@ -85,14 +77,6 @@ export default class RightPanelStore extends ReadyWatchingStore { isOpen: boolean; history: Array; } = null; - // private byGroup: { - // [groupId: string]: { - // isOpen: boolean; - // history: Array; - // }; - // }; - // private state: RightPanelStoreState; - // private lastRoomId: string; private constructor() { super(defaultDispatcher); @@ -111,35 +95,21 @@ export default class RightPanelStore extends ReadyWatchingStore { } } - // get isOpenForRoom(roomId:): boolean { - // return this.state.showRoomPanel; - // } // ALL GETTERS: get isOpenForRoom(): boolean { - // return this.state.isOpen ?? false; return this.byRoom[this.viewedRoomId]?.isOpen ?? false; } - // get isOpenForGroup(): boolean { - // return this.state.showGroupPanel; - // } - get isOpenForGroup(): boolean { // return this.state.isOpen ?? false; return this.isOpenForRoom; // return this.byRoom[this.viewedRoomId]?.isOpen; } - // get roomPanelPhase(): RightPanelPhases { - // return this.state.lastRoomPhase; - // } get roomPhaseHistory(): Array { - // return this.state.panelHistory; - // if (!this.viewedRoomId) return null; return this.byRoom[this.viewedRoomId]?.history ?? []; } get currentPanel(): IPhaseAndState { - // return this.state.currentPanel ?? { state: {}, phase: null }; const hist = this.roomPhaseHistory; if (hist.length >= 1) { return hist[hist.length - 1]; @@ -152,47 +122,24 @@ export default class RightPanelStore extends ReadyWatchingStore { return hist[hist.length - 1]; } return this.currentPanel ?? { state: {}, phase: null }; - // const hist = this.roomPhaseHistory; - // if (hist.length >= 1) { - // return hist[hist.length - 1]; - // } - // return null; } - get previousRoom(): IPhaseAndState { - // const roomCache = cacheGlobal ?? cacheThisRoom; + get previousPanel(): IPhaseAndState { const hist = this.roomPhaseHistory; if (hist?.length >= 2) { return hist[hist.length - 2]; } return { state: {}, phase: null }; - // const hist = this.roomPhaseHistory; - // if (hist.length >= 2) { - // return hist[hist.length - 2]; - // } } - // get groupPanelPhase(): RightPanelPhases { - // return this.state.lastGroupPhase; - // } + + // The Group stuff is just for backwards compatibility. Can be removed when depracating groups get groupPhaseHistory(): Array { return this.roomPhaseHistory; - // if (!this.viewedGroupId) return null; - // return this.state.byRoom[this.viewedGroupId]?.history ?? []; } get currentGroup(): IPhaseAndState { return this.currentPanel; - // const hist = this.groupPhaseHistory; - // if (hist.length >= 1) { - // return hist[hist.length - 1]; - // } - // return null; } get previousGroup(): IPhaseAndState { - return this.previousRoom; - // const hist = this.groupPhaseHistory; - // if (hist.length >= 2) { - // return hist[hist.length - 2]; - // } - // return null; + return this.previousPanel; } // ALL SETTERS: @@ -228,6 +175,7 @@ export default class RightPanelStore extends ReadyWatchingStore { this.setRightPanelCache(targetPhase, panelState); } } + // push right panel: appends to the history public pushRightPanel( phase: RightPanelPhases, @@ -260,6 +208,7 @@ export default class RightPanelStore extends ReadyWatchingStore { this.emitAndUpdateSettings(); } + // pop right panel: removes last eelemnt from history public popRightPanel(roomId: string = null) { const rId = roomId ?? this.viewedRoomId; @@ -273,69 +222,8 @@ export default class RightPanelStore extends ReadyWatchingStore { this.byRoom[rId].isOpen = !this.byRoom[rId].isOpen; this.emitAndUpdateSettings(); } - // get previousPhase(): RightPanelPhases | null { - // return RIGHT_PANEL_PHASES_NO_ARGS.includes(this.state.previousPhase) ? this.state.previousPhase : null; - // } - - // get visibleRoomPanelPhase(): RightPanelPhases { - // return this.isOpenForRoom ? this.roomPanelPhase : null; - // } - - // get visibleGroupPanelPhase(): RightPanelPhases { - // return this.isOpenForGroup ? this.groupPanelPhase : null; - // } - - // get roomPanelPhaseParams(): any { - // return this.state.lastRoomPhaseParams || {}; - // } - - // private setState(newState: Partial) { - // this.updateState(newState); - - // SettingsStore.setValue( - // "showRightPanelInRoom", - // null, - // SettingLevel.DEVICE, - // this.state.showRoomPanel, - // ); - // SettingsStore.setValue( - // "showRightPanelInGroup", - // null, - // SettingLevel.DEVICE, - // this.state.showGroupPanel, - // ); - - // if (RIGHT_PANEL_PHASES_NO_ARGS.includes(this.state.lastRoomPhase)) { - // SettingsStore.setValue( - // "lastRightPanelPhaseForRoom", - // null, - // SettingLevel.DEVICE, - // this.state.lastRoomPhase, - // ); - // } - // if (RIGHT_PANEL_PHASES_NO_ARGS.includes(this.state.lastGroupPhase)) { - // SettingsStore.setValue( - // "lastRightPanelPhaseForGroup", - // null, - // SettingLevel.DEVICE, - // this.state.lastGroupPhase, - // ); - // } - // } - // getCurrentRoomCache() { - // if (!!this.global) { - // return this.global; - // } else { - // return this.byRoom[this.viewedRoomId]; - // } - // } - // setCurrentRoomCache(roomCache, global) { - // if (!!global) { - // this.global = roomCache; - // } else { - // this.byRoom[this.viewedRoomId] = roomCache; - // } - // } + + // Private private loadCacheFromSettings() { this.global = this.global ?? SettingsStore.getValue("RightPanel.phasesGlobal"); this.byRoom[this.viewedRoomId] = this.byRoom[this.viewedRoomId] @@ -349,14 +237,8 @@ export default class RightPanelStore extends ReadyWatchingStore { SettingsStore.setValue("RightPanel.phases", this.viewedRoomId, SettingLevel.ROOM_DEVICE, cacheThisRoom); } this.emit(UPDATE_EVENT, null); - // this.updateState({ - // isOpen: roomCache?.isOpen ?? false, - // currentPanel: current, - // previousPanel: previous, - // panelHistory: hist, - // }); } - // NEEDED: + // set rigth panel: overrides the history private setRightPanelCache(targetPhase: RightPanelPhases, panelState: IPanelState = null) { this.byRoom[this.viewedRoomId] = { @@ -365,9 +247,9 @@ export default class RightPanelStore extends ReadyWatchingStore { }; this.emitAndUpdateSettings(); } + // CHECKS: // - RoomMemberInfo -> needs to be changed to EncryptionPanel if pendingVerificationRequestForUser - // - hide/show when setting the same panel twice private getVerificationRedirect(targetPhase: RightPanelPhases, panelState): { targetPhase: RightPanelPhases, panelState } { if (targetPhase === RightPanelPhases.RoomMemberInfo && panelState) { @@ -411,7 +293,6 @@ export default class RightPanelStore extends ReadyWatchingStore { } onDispatch(payload: ActionPayload) { - // __onDispatch(payload: ActionPayload) { // eslint-disable-line @typescript-eslint/naming-convention switch (payload.action) { case 'view_group': case Action.ViewRoom: { @@ -443,162 +324,7 @@ export default class RightPanelStore extends ReadyWatchingStore { _this.emitAndUpdateSettings(); console.log("right panel store for current room: ", _this.byRoom[_this.viewedRoomId]); break; - - // Reset to the member list if we're viewing member info } - - // case 'view_group': - // this.viewedGroupId = payload.room_id; - // this.viewedRoomId = undefined; - - // Not necassary anymore since we store everything per room/ per group - // this.lastRoomId = payload.room_id; - - // // Reset to the member list if we're viewing member info - // if (MEMBER_INFO_PHASES.includes(this.currentRoomPhaseState.phase)) { - // this.setState({ lastRoomPhase: RightPanelPhases.RoomMemberList, lastRoomPhaseParams: {} }); - // } - - // // Do the same for groups - // if (this.state.lastGroupPhase === RightPanelPhases.GroupMemberInfo) { - // this.setState({ lastGroupPhase: RightPanelPhases.GroupMemberList }); - // } - // break; - - // case Action.SetRightPanelPhase: { - // console.log("ORDER_DEBUG: action:", Action.SetRightPanelPhase); - // // this was previously a very multifuncitonal command: - // // TogglePanel: if the same phase is send but without refireParams - // // UpdateState: if the same phase is send but with refireParams - // // SetRightPanel and erase history: if a "differnt to the current" phase is send (with or without refireParams) - // const redirect = this.getVerificationRedirect(payload, payload.phase); - // const targetPhase = redirect?.targetPhase ?? payload.phase; - // const refireParams = redirect?.refireParams ?? payload.refireParams; - - // const allowClose = payload.allowClose ?? true; - - // // Checks for wrong SetRightPanelPhase requests - // if (!this.isPhaseActionIsValid(targetPhase)) break; - - // if (targetPhase === this.currentRoom?.phase && allowClose && !refireParams) { - // // Toggle command: a toggle command needs to fullfill the following: - // // - the same phase - // // - the panel can be closed - // // - does not contain any state information (refireParams) - // this.togglePanel(); - // break; - // } else if ((targetPhase === this.currentRoom?.phase && !!refireParams)) { - // // Update Command: set right panel phase with a new state but keep the phase (dont know it this is ever needed...) - // const hist = this.byRoom[this.viewedRoomId].history; - // hist[hist.length - 1].state = refireParams; - // this.updateStateAndSettingsFromCache(); - // break; - // } else if (targetPhase !== this.currentRoom?.phase) { - // // SetRightPanel and erase history. - // this.setRightPanel(targetPhase, refireParams); - // // this.byRoom[this.viewedRoomId] = { - // // history: [{ phase: targetPhase, state: refireParams }], - // // isOpen: true, - // // }; - // // this.updateStateFromCache(); - // } - // // redirect to EncryptionPanel if there is an ongoing verification request - // // if (targetPhase === RightPanelPhases.RoomMemberInfo && payload.refireParams) { - // // const { member } = payload.refireParams; - // // const pendingRequest = pendingVerificationRequestForUser(member); - // // if (pendingRequest) { - // // targetPhase = RightPanelPhases.EncryptionPanel; - // // refireParams = { - // // verificationRequest: pendingRequest, - // // member, - // // }; - // // } - // // } - - // // if (GROUP_PHASES.includes(targetPhase)) { - // // if (targetPhase === this.state.lastGroupPhase) { - // // // hide when already open - // // this.setState({ - // // showGroupPanel: !this.state.showGroupPanel, - // // previousPhase: null, - // // }); - // // } else { - // // this.setState({ - // // lastGroupPhase: targetPhase, - // // showGroupPanel: true, - // // previousPhase: this.state.lastGroupPhase, - // // }); - // // } - // // } else { - // // if (targetPhase === this.state.lastRoomPhase && !refireParams && allowClose) { - // // this.setState({ - // // showRoomPanel: !this.state.showRoomPanel, - // // previousPhase: null, - // // }); - // // } else { - // // this.setState({ - // // lastRoomPhase: targetPhase, - // // showRoomPanel: true, - // // lastRoomPhaseParams: refireParams || {}, - // // previousPhase: this.state.lastRoomPhase, - // // }); - // // } - // // } - - // // Let things like the member info panel actually open to the right member. - // // Dont do the dispatch anymore, instead use a listener - // // defaultDispatcher.dispatch({ - // // action: Action.AfterRightPanelPhaseChange, - // // phase: targetPhase, - // // ...(refireParams || {}), - // // }); - // break; - // } - // case Action.PushRightPanelPhase: { - // console.log("ORDER_DEBUG: action:", payload.action); - // const redirect = this.getVerificationRedirect(payload, payload.phase); - // const targetPhase = redirect?.targetPhase ?? payload.phase; - // const refireParams = redirect?.refireParams ?? payload.refireParams; - - // const allowClose = payload.allowClose ?? true; - - // // Checks for wrong SetRightPanelPhase requests - // if (!this.isPhaseActionIsValid(targetPhase)) break; - - // let roomCache = this.byRoom[this.viewedRoomId]; - // if (!!roomCache) { - // // append new phase - // roomCache.history.push({ state: refireParams, phase: targetPhase }); - // roomCache.isOpen = allowClose ? roomCache.isOpen : true; - // } else { - // // create new phase - // roomCache = { - // history: [{ phase: targetPhase, state: refireParams }], - // // if there was no right panel store object the the panel was closed -> keep it closed, except if allowClose==false - // isOpen: !allowClose, - // }; - // } - - // this.updateStateAndSettingsFromCache(); - // break; - // } - // case Action.PopRightPanelPhase: { - // const roomCache = this.byRoom[this.viewedRoomId]; - // roomCache.history.pop(); - // this.updateStateAndSettingsFromCache(); - // break; - // } - - // case Action.ToggleRightPanel: - // console.log("ORDER_DEBUG: action:", payload.action); - // this.togglePanel(); - // break; - // if (payload.type === "room") { - // this.setState({ showRoomPanel: !this.state.showRoomPanel }); - // } else { // group - // this.setState({ showGroupPanel: !this.state.showGroupPanel }); - // } - // break; } } public static get instance(): RightPanelStore { diff --git a/src/verification.ts b/src/verification.ts index 4cb54bab196..6b5e9956975 100644 --- a/src/verification.ts +++ b/src/verification.ts @@ -69,11 +69,6 @@ export async function verifyDevice(user: User, device: IDevice) { RightPanelPhases.EncryptionPanel, { member: user, verificationRequestPromise }, ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.EncryptionPanel, - // refireParams: { member: user, verificationRequestPromise }, - // }); } else if (action === "legacy") { Modal.createTrackedDialog("Legacy verify session", "legacy verify session", ManualDeviceKeyVerificationDialog, @@ -104,11 +99,6 @@ export async function legacyVerifyUser(user: User) { RightPanelPhases.EncryptionPanel, { member: user, verificationRequestPromise }, ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.EncryptionPanel, - // refireParams: { member: user, verificationRequestPromise }, - // }); } export async function verifyUser(user: User) { @@ -125,14 +115,6 @@ export async function verifyUser(user: User) { RightPanelPhases.EncryptionPanel, { member: user, verificationRequest: existingRequest }, ); - // dis.dispatch({ - // action: Action.SetRightPanelPhase, - // phase: RightPanelPhases.EncryptionPanel, - // refireParams: { - // member: user, - // verificationRequest: existingRequest, - // }, - // }); } export function pendingVerificationRequestForUser(user: User) {