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

Commit 7741ab6

Browse files
committed
Cope with the list ending with events not to show
1 parent 80dd553 commit 7741ab6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/structures/MessagePanel.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,11 @@ export default class MessagePanel extends React.Component<IProps, IState> {
433433
const currentEventId =
434434
this.focusedEventId ||
435435
this.props.highlightedEventId ||
436-
(events[events.length - 1] ? events[events.length - 1].event.getId()! : null);
436+
events.reduce(
437+
// Get the id of the last event in the list that's shown.
438+
(prev, { event, shouldShow }) => shouldShow ? event.getId() : prev,
439+
null as string | null,
440+
);
437441
if (navAction === KeyBindingAction.SelectPrevMessage) {
438442
events.reverse();
439443
}

0 commit comments

Comments
 (0)