Fix sending wrong read recipt

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-16 18:29:42 +05:30
parent db58e87a35
commit 54d89d2321
2 changed files with 4 additions and 4 deletions

View file

@ -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());
}
};

View file

@ -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);