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

Commit

Permalink
Update lastReply to filter out local event ID from thread fallback (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain authored Jan 25, 2022
1 parent 1d02e61 commit ecd5be8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/structures/ThreadPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions src/components/structures/ThreadView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ export default class ThreadView extends React.Component<IProps, IState> {
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();
Expand All @@ -177,7 +179,9 @@ export default class ThreadView extends React.Component<IProps, IState> {
private updateLastThreadReply = () => {
if (this.state.thread) {
this.setState({
lastThreadReply: this.state.thread.lastReply,
lastThreadReply: this.state.thread.lastReply((ev: MatrixEvent) => {
return !ev.status;
}),
});
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export default class EventTile extends React.Component<IProps, IState> {

thread,
threadReplyCount: thread?.length,
threadLastReply: thread?.lastReply,
threadLastReply: thread?.lastReply(),
};

// don't do RR animations until we are mounted
Expand Down Expand Up @@ -556,7 +556,7 @@ export default class EventTile extends React.Component<IProps, IState> {
}

this.setState({
threadLastReply: thread?.lastReply,
threadLastReply: thread?.lastReply(),
threadReplyCount: thread?.length,
thread,
});
Expand Down Expand Up @@ -1271,7 +1271,7 @@ export default class EventTile extends React.Component<IProps, IState> {
// 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 ?
<MessageTimestamp
Expand Down

0 comments on commit ecd5be8

Please sign in to comment.