Fix msg timeline keep scrolling when not in focus
authorAjay Bura <ajbura@gmail.com>
Wed, 15 Dec 2021 11:56:22 +0000 (17:26 +0530)
committerAjay Bura <ajbura@gmail.com>
Wed, 15 Dec 2021 11:56:22 +0000 (17:26 +0530)
Signed-off-by: Ajay Bura <ajbura@gmail.com>
src/app/organisms/room/RoomViewContent.jsx

index c26fbd80b27a3468eeef67ec275fe280b97f08e6..364d35d1f69ccbc17b88422aebd570d03842fb25 100644 (file)
@@ -453,6 +453,8 @@ function useEventArrive(roomTimeline, readEventStore) {
         readEventStore.setItem(roomTimeline.findEventByIdInTimelineSet(readUpToId));
         return;
       }
+
+      // user has not mark room as read
       const isUnreadMsg = readUpToEvent?.getId() === readUpToId;
       if (!isUnreadMsg) {
         roomTimeline.markAllAsRead();
@@ -509,6 +511,8 @@ function useEventArrive(roomTimeline, readEventStore) {
       && !roomTimeline.canPaginateForward()
       && document.visibilityState === 'visible') {
       timelineScroll.scrollToBottom();
+    } else {
+      timelineScroll.tryRestoringScroll();
     }
   }, [newEvent, roomTimeline]);
 }