Fix crashes
authorAjay Bura <ajbura@gmail.com>
Fri, 10 Dec 2021 06:15:43 +0000 (11:45 +0530)
committerAjay Bura <ajbura@gmail.com>
Fri, 10 Dec 2021 06:15:43 +0000 (11:45 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/organisms/room/RoomViewContent.jsx
src/app/organisms/room/RoomViewFloating.jsx

index 2b2a2749362940df3ada2998e6bf7563292e7d3a..f78cbdab8816d83e02c5dd80bc580f6d6852b7db 100644 (file)
@@ -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());
         }
       }
index b85a28f2b51328049341287230c6073f4b146d3f..1bec52d210971ee09562a27ed28fa03977efaaaf 100644 (file)
@@ -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);
     }