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

Commit bd2f4b6

Browse files
authored
Fix thread switching sometimes stuck (#7079)
1 parent 3875020 commit bd2f4b6

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/components/structures/ThreadView.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ export default class ThreadView extends React.Component<IProps, IState> {
100100

101101
private onAction = (payload: ActionPayload): void => {
102102
if (payload.phase == RightPanelPhases.ThreadView && payload.event) {
103-
if (payload.event !== this.props.mxEvent) {
104-
this.teardownThread();
105-
this.setupThread(payload.event);
106-
}
103+
this.teardownThread();
104+
this.setupThread(payload.event);
107105
}
108106
switch (payload.action) {
109107
case Action.EditEvent:
@@ -135,12 +133,15 @@ export default class ThreadView extends React.Component<IProps, IState> {
135133
let thread = mxEv.getThread();
136134
if (!thread) {
137135
const client = MatrixClientPeg.get();
136+
// Do not attach this thread object to the event for now
137+
// TODO: When local echo gets reintroduced it will be important
138+
// to add that back in, and the threads model should go through the
139+
// same reconciliation algorithm as events
138140
thread = new Thread(
139141
[mxEv],
140142
this.props.room,
141143
client,
142144
);
143-
mxEv.setThread(thread);
144145
}
145146
thread.on(ThreadEvent.Update, this.updateThread);
146147
thread.once(ThreadEvent.Ready, this.updateThread);
@@ -226,7 +227,6 @@ export default class ThreadView extends React.Component<IProps, IState> {
226227
timelineSet={this.state?.thread?.timelineSet}
227228
showUrlPreview={true}
228229
tileShape={TileShape.Thread}
229-
empty={<div>empty</div>}
230230
layout={Layout.Group}
231231
hideThreadedMessages={false}
232232
hidden={false}

src/components/views/messages/MessageActionBar.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { _t } from '../../../languageHandler';
2424
import * as sdk from '../../../index';
2525
import dis from '../../../dispatcher/dispatcher';
2626
import { Action } from '../../../dispatcher/actions';
27-
import { RightPanelPhases } from '../../../stores/RightPanelStorePhases';
2827
import { aboveLeftOf, ContextMenu, ContextMenuTooltipButton, useContextMenu } from '../../structures/ContextMenu';
2928
import { isContentActionable, canEditContent } from '../../../utils/EventUtils';
3029
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
@@ -42,6 +41,7 @@ import classNames from 'classnames';
4241
import SettingsStore from '../../../settings/SettingsStore';
4342
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
4443
import ReplyChain from '../elements/ReplyChain';
44+
import { dispatchShowThreadEvent } from '../../../dispatcher/dispatch-actions/threads';
4545

4646
interface IOptionsButtonProps {
4747
mxEvent: MatrixEvent;
@@ -196,14 +196,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
196196
};
197197

198198
private onThreadClick = (): void => {
199-
dis.dispatch({
200-
action: Action.SetRightPanelPhase,
201-
phase: RightPanelPhases.ThreadView,
202-
allowClose: false,
203-
refireParams: {
204-
event: this.props.mxEvent,
205-
},
206-
});
199+
dispatchShowThreadEvent(this.props.mxEvent);
207200
};
208201

209202
private onEditClick = (ev: React.MouseEvent): void => {

0 commit comments

Comments
 (0)