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

Commit

Permalink
Make view_room option open the thread view if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain Souquet committed Oct 20, 2021
1 parent 7f6df08 commit 5109b2d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import SpaceStore from "../../stores/SpaceStore";

import { logger } from "matrix-js-sdk/src/logger";
import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline';
import { dispatchShowThreadEvent } from '../../dispatcher/dispatch-actions/threads';

const DEBUG = false;
let debuglog = function(msg: string) {};
Expand Down Expand Up @@ -347,8 +348,6 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
roomLoading: RoomViewStore.isRoomLoading(),
roomLoadError: RoomViewStore.getRoomLoadError(),
joining: RoomViewStore.isJoining(),
initialEventId: RoomViewStore.getInitialEventId(),
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
replyToEvent: RoomViewStore.getQuotingEvent(),
// we should only peek once we have a ready client
shouldPeek: this.state.matrixClientIsReady && RoomViewStore.shouldPeek(),
Expand All @@ -360,6 +359,18 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
wasContextSwitch: RoomViewStore.getWasContextSwitch(),
};

const initialEventId = RoomViewStore.getInitialEventId();
if (initialEventId) {
const event = this.state.room.findEventById(initialEventId);
const thread = event?.getThread();
if (thread && !event?.isThreadRoot) {
dispatchShowThreadEvent(thread.rootEvent);
} else {
newState.initialEventId = initialEventId;
newState.isInitialEventHighlighted = RoomViewStore.isInitialEventHighlighted();
}
}

// Add watchers for each of the settings we just looked up
this.settingWatchers = this.settingWatchers.concat([
SettingsStore.watchSetting("showReadReceipts", roomId, (...[,,, value]) =>
Expand Down

0 comments on commit 5109b2d

Please sign in to comment.