From c26f3b8a97a3cf52363883b874587ffcf2da1a2b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 9 Sep 2020 16:52:46 +0100 Subject: [PATCH] Fix onNewScreen to use replace when going from roomId->roomAlias to prevent locking the user in place --- src/components/structures/MatrixChat.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index 176aaf95a3..d3d5835dae 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -147,7 +147,7 @@ interface IProps { // TODO type things better config: Record; serverConfig?: ValidatedServerConfig; ConferenceHandler?: any; - onNewScreen: (string) => void; + onNewScreen: (screen: string, replaceLast: boolean) => void; enableGuest?: boolean; // the queryParams extracted from the [real] query-string of the URI realQueryParams?: Record; @@ -886,6 +886,9 @@ export default class MatrixChat extends React.PureComponent { } } + // If we are redirecting to a Room Alias and it is for the room we already showing then replace history item + const replaceLast = presentedId[0] === "#" && roomInfo.room_id === this.state.currentRoomId; + if (roomInfo.event_id && roomInfo.highlighted) { presentedId += "/" + roomInfo.event_id; } @@ -898,7 +901,7 @@ export default class MatrixChat extends React.PureComponent { viaServers: roomInfo.via_servers, ready: true, }, () => { - this.notifyNewScreen('room/' + presentedId); + this.notifyNewScreen('room/' + presentedId, replaceLast); }); }); } @@ -1699,9 +1702,9 @@ export default class MatrixChat extends React.PureComponent { } } - notifyNewScreen(screen: string) { + notifyNewScreen(screen: string, replaceLast = false) { if (this.props.onNewScreen) { - this.props.onNewScreen(screen); + this.props.onNewScreen(screen, replaceLast); } this.setPageSubtitle(); }