Fix thread switching sometimes stuck (#7079)

pull/21833/head
Germain 2021-11-03 18:17:05 +00:00 committed by GitHub
parent 38750202ee
commit bd2f4b6c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 15 deletions

View File

@ -100,10 +100,8 @@ export default class ThreadView extends React.Component<IProps, IState> {
private onAction = (payload: ActionPayload): void => { private onAction = (payload: ActionPayload): void => {
if (payload.phase == RightPanelPhases.ThreadView && payload.event) { if (payload.phase == RightPanelPhases.ThreadView && payload.event) {
if (payload.event !== this.props.mxEvent) { this.teardownThread();
this.teardownThread(); this.setupThread(payload.event);
this.setupThread(payload.event);
}
} }
switch (payload.action) { switch (payload.action) {
case Action.EditEvent: case Action.EditEvent:
@ -135,12 +133,15 @@ export default class ThreadView extends React.Component<IProps, IState> {
let thread = mxEv.getThread(); let thread = mxEv.getThread();
if (!thread) { if (!thread) {
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
// Do not attach this thread object to the event for now
// TODO: When local echo gets reintroduced it will be important
// to add that back in, and the threads model should go through the
// same reconciliation algorithm as events
thread = new Thread( thread = new Thread(
[mxEv], [mxEv],
this.props.room, this.props.room,
client, client,
); );
mxEv.setThread(thread);
} }
thread.on(ThreadEvent.Update, this.updateThread); thread.on(ThreadEvent.Update, this.updateThread);
thread.once(ThreadEvent.Ready, this.updateThread); thread.once(ThreadEvent.Ready, this.updateThread);
@ -226,7 +227,6 @@ export default class ThreadView extends React.Component<IProps, IState> {
timelineSet={this.state?.thread?.timelineSet} timelineSet={this.state?.thread?.timelineSet}
showUrlPreview={true} showUrlPreview={true}
tileShape={TileShape.Thread} tileShape={TileShape.Thread}
empty={<div>empty</div>}
layout={Layout.Group} layout={Layout.Group}
hideThreadedMessages={false} hideThreadedMessages={false}
hidden={false} hidden={false}

View File

@ -24,7 +24,6 @@ import { _t } from '../../../languageHandler';
import * as sdk from '../../../index'; import * as sdk from '../../../index';
import dis from '../../../dispatcher/dispatcher'; import dis from '../../../dispatcher/dispatcher';
import { Action } from '../../../dispatcher/actions'; import { Action } from '../../../dispatcher/actions';
import { RightPanelPhases } from '../../../stores/RightPanelStorePhases';
import { aboveLeftOf, ContextMenu, ContextMenuTooltipButton, useContextMenu } from '../../structures/ContextMenu'; import { aboveLeftOf, ContextMenu, ContextMenuTooltipButton, useContextMenu } from '../../structures/ContextMenu';
import { isContentActionable, canEditContent } from '../../../utils/EventUtils'; import { isContentActionable, canEditContent } from '../../../utils/EventUtils';
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext"; import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
@ -42,6 +41,7 @@ import classNames from 'classnames';
import SettingsStore from '../../../settings/SettingsStore'; import SettingsStore from '../../../settings/SettingsStore';
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks'; import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
import ReplyChain from '../elements/ReplyChain'; import ReplyChain from '../elements/ReplyChain';
import { dispatchShowThreadEvent } from '../../../dispatcher/dispatch-actions/threads';
interface IOptionsButtonProps { interface IOptionsButtonProps {
mxEvent: MatrixEvent; mxEvent: MatrixEvent;
@ -196,14 +196,7 @@ export default class MessageActionBar extends React.PureComponent<IMessageAction
}; };
private onThreadClick = (): void => { private onThreadClick = (): void => {
dis.dispatch({ dispatchShowThreadEvent(this.props.mxEvent);
action: Action.SetRightPanelPhase,
phase: RightPanelPhases.ThreadView,
allowClose: false,
refireParams: {
event: this.props.mxEvent,
},
});
}; };
private onEditClick = (ev: React.MouseEvent): void => { private onEditClick = (ev: React.MouseEvent): void => {