diff --git a/src/app/organisms/room/RoomViewContent.jsx b/src/app/organisms/room/RoomViewContent.jsx index 2dffbceb..e3f2aba4 100644 --- a/src/app/organisms/room/RoomViewContent.jsx +++ b/src/app/organisms/room/RoomViewContent.jsx @@ -285,9 +285,8 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event const timelineScroll = timelineScrollRef.current; const limit = eventLimitRef.current; const trySendReadReceipt = (event) => { - if (event.isSending()) return; if (myUserId === event.getSender()) { - roomTimeline.markAllAsRead(); + requestAnimationFrame(() => roomTimeline.markAllAsRead()); return; } const readUpToEvent = readUptoEvtStore.getItem(); @@ -296,7 +295,7 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event if (isUnread === false) { if (document.visibilityState === 'visible' && timelineScroll.bottom < 16) { - roomTimeline.markAllAsRead(); + requestAnimationFrame(() => roomTimeline.markAllAsRead()); } else { readUptoEvtStore.setItem(roomTimeline.findEventByIdInTimelineSet(readUpToId)); } @@ -306,7 +305,7 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event const { timeline } = roomTimeline; const unreadMsgIsLast = timeline[timeline.length - 2].getId() === readUpToId; if (unreadMsgIsLast) { - roomTimeline.markAllAsRead(); + requestAnimationFrame(() => roomTimeline.markAllAsRead()); } }; diff --git a/src/client/state/RoomTimeline.js b/src/client/state/RoomTimeline.js index f4911864..c0895b08 100644 --- a/src/client/state/RoomTimeline.js +++ b/src/client/state/RoomTimeline.js @@ -233,6 +233,7 @@ class RoomTimeline extends EventEmitter { this.notifications.deleteNoti(this.roomId); if (this.timeline.length === 0) return; const latestEvent = this.timeline[this.timeline.length - 1]; + if (latestEvent.isSending() || latestEvent.getId().startsWith('~')) return; if (readEventId === latestEvent.getId()) return; this.matrixClient.sendReadReceipt(latestEvent); this.emit(cons.events.roomTimeline.MARKED_AS_READ, latestEvent);