From ecd5be8a8f842f757430ccdc4cc1e2d5b3bb66e7 Mon Sep 17 00:00:00 2001 From: Germain Date: Tue, 25 Jan 2022 10:51:17 +0000 Subject: [PATCH] Update lastReply to filter out local event ID from thread fallback (#7620) --- src/components/structures/ThreadPanel.tsx | 2 +- src/components/structures/ThreadView.tsx | 8 ++++++-- src/components/views/rooms/EventTile.tsx | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/structures/ThreadPanel.tsx b/src/components/structures/ThreadPanel.tsx index 3aa1d2eec8..0d279dc1d9 100644 --- a/src/components/structures/ThreadPanel.tsx +++ b/src/components/structures/ThreadPanel.tsx @@ -88,7 +88,7 @@ async function getThreadTimelineSet( const timelineSet = new EventTimelineSet(room, {}); Array.from(room.threads) - .sort(([, threadA], [, threadB]) => threadA.lastReply.getTs() - threadB.lastReply.getTs()) + .sort(([, threadA], [, threadB]) => threadA.lastReply().getTs() - threadB.lastReply().getTs()) .forEach(([, thread]) => { const isOwnEvent = thread.rootEvent.getSender() === client.getUserId(); if (filterType !== ThreadFilterType.My || isOwnEvent) { diff --git a/src/components/structures/ThreadView.tsx b/src/components/structures/ThreadView.tsx index 97b255d4e8..f472946aee 100644 --- a/src/components/structures/ThreadView.tsx +++ b/src/components/structures/ThreadView.tsx @@ -166,7 +166,9 @@ export default class ThreadView extends React.Component { if (thread && this.state.thread !== thread) { this.setState({ thread, - lastThreadReply: thread.lastReply, + lastThreadReply: thread.lastReply((ev: MatrixEvent) => { + return !ev.status; + }), }, () => { thread.emit(ThreadEvent.ViewThread); this.timelinePanelRef.current?.refreshTimeline(); @@ -177,7 +179,9 @@ export default class ThreadView extends React.Component { private updateLastThreadReply = () => { if (this.state.thread) { this.setState({ - lastThreadReply: this.state.thread.lastReply, + lastThreadReply: this.state.thread.lastReply((ev: MatrixEvent) => { + return !ev.status; + }), }); } }; diff --git a/src/components/views/rooms/EventTile.tsx b/src/components/views/rooms/EventTile.tsx index 956998a9fe..9275558d21 100644 --- a/src/components/views/rooms/EventTile.tsx +++ b/src/components/views/rooms/EventTile.tsx @@ -402,7 +402,7 @@ export default class EventTile extends React.Component { thread, threadReplyCount: thread?.length, - threadLastReply: thread?.lastReply, + threadLastReply: thread?.lastReply(), }; // don't do RR animations until we are mounted @@ -556,7 +556,7 @@ export default class EventTile extends React.Component { } this.setState({ - threadLastReply: thread?.lastReply, + threadLastReply: thread?.lastReply(), threadReplyCount: thread?.length, thread, }); @@ -1271,7 +1271,7 @@ export default class EventTile extends React.Component { // Thread panel shows the timestamp of the last reply in that thread const ts = this.props.tileShape !== TileShape.ThreadPanel ? this.props.mxEvent.getTs() - : thread?.lastReply.getTs(); + : thread?.lastReply().getTs(); const timestamp = showTimestamp && ts ?