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

Add a bit of safety around timestamp handling for threads #8845

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/views/rooms/EventTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,13 @@ export class UnwrappedEventTile extends React.Component<IProps, IState> {
|| Boolean(this.state.contextMenu));

// Thread panel shows the timestamp of the last reply in that thread
const ts = this.context.timelineRenderingType !== TimelineRenderingType.ThreadsList
let ts = this.context.timelineRenderingType !== TimelineRenderingType.ThreadsList
? this.props.mxEvent.getTs()
: this.state.thread?.replyToEvent.getTs();
: this.state.thread?.replyToEvent?.getTs();
if (typeof ts !== "number") {
// Fall back to something we can use
ts = this.props.mxEvent.getTs();
}
Comment on lines +1124 to +1130
Copy link
Member

@t3chguy t3chguy Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this would have been more readable as

        let ts = this.props.mxEvent.getTs();
        if (this.context.timelineRenderingType === TimelineRenderingType.ThreadsList &&
            this.state.thread?.replyToEvent
        ) {
            ts = this.state.thread?.replyToEvent.getTs();
        }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, this looks quite a bit better


const messageTimestamp = <MessageTimestamp
showRelative={this.context.timelineRenderingType === TimelineRenderingType.ThreadsList}
Expand Down