Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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