From 20443f8a4da7f064a38a21f9794c15f4c3f75aa8 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Fri, 10 Dec 2021 11:45:43 +0530 Subject: [PATCH] Fix crashes Signed-off-by: Ajay Bura --- src/app/organisms/room/RoomViewContent.jsx | 3 ++- src/app/organisms/room/RoomViewFloating.jsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/organisms/room/RoomViewContent.jsx b/src/app/organisms/room/RoomViewContent.jsx index 2b2a274..f78cbda 100644 --- a/src/app/organisms/room/RoomViewContent.jsx +++ b/src/app/organisms/room/RoomViewContent.jsx @@ -534,7 +534,8 @@ function RoomViewContent({ eventId, roomTimeline }) { timelineScroll.scrollToIndex(jumpToItemIndex, 80); } if (timelineScroll.bottom < 16 && !roomTimeline.canPaginateForward()) { - if (readEventStore.getItem()?.getId() === roomTimeline.getReadUpToEventId()) { + const readUpToId = roomTimeline.getReadUpToEventId(); + if (readEventStore.getItem()?.getId() === readUpToId || readUpToId === null) { requestAnimationFrame(() => roomTimeline.markAllAsRead()); } } diff --git a/src/app/organisms/room/RoomViewFloating.jsx b/src/app/organisms/room/RoomViewFloating.jsx index b85a28f..1bec52d 100644 --- a/src/app/organisms/room/RoomViewFloating.jsx +++ b/src/app/organisms/room/RoomViewFloating.jsx @@ -32,7 +32,7 @@ function useJumpToEvent(roomTimeline) { // we only show "Jump to unread" btn only if the event is not in timeline. // if event is in timeline // we will automatically open the timeline from that event position - if (!readEventId.startsWith('~') && !roomTimeline.hasEventInTimeline(readEventId)) { + if (!readEventId?.startsWith('~') && !roomTimeline.hasEventInTimeline(readEventId)) { setEventId(readEventId); }