Fix sending wrong read recipt
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
db58e87a35
commit
54d89d2321
2 changed files with 4 additions and 4 deletions
|
@ -285,9 +285,8 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event
|
||||||
const timelineScroll = timelineScrollRef.current;
|
const timelineScroll = timelineScrollRef.current;
|
||||||
const limit = eventLimitRef.current;
|
const limit = eventLimitRef.current;
|
||||||
const trySendReadReceipt = (event) => {
|
const trySendReadReceipt = (event) => {
|
||||||
if (event.isSending()) return;
|
|
||||||
if (myUserId === event.getSender()) {
|
if (myUserId === event.getSender()) {
|
||||||
roomTimeline.markAllAsRead();
|
requestAnimationFrame(() => roomTimeline.markAllAsRead());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const readUpToEvent = readUptoEvtStore.getItem();
|
const readUpToEvent = readUptoEvtStore.getItem();
|
||||||
|
@ -296,7 +295,7 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event
|
||||||
|
|
||||||
if (isUnread === false) {
|
if (isUnread === false) {
|
||||||
if (document.visibilityState === 'visible' && timelineScroll.bottom < 16) {
|
if (document.visibilityState === 'visible' && timelineScroll.bottom < 16) {
|
||||||
roomTimeline.markAllAsRead();
|
requestAnimationFrame(() => roomTimeline.markAllAsRead());
|
||||||
} else {
|
} else {
|
||||||
readUptoEvtStore.setItem(roomTimeline.findEventByIdInTimelineSet(readUpToId));
|
readUptoEvtStore.setItem(roomTimeline.findEventByIdInTimelineSet(readUpToId));
|
||||||
}
|
}
|
||||||
|
@ -306,7 +305,7 @@ function useEventArrive(roomTimeline, readUptoEvtStore, timelineScrollRef, event
|
||||||
const { timeline } = roomTimeline;
|
const { timeline } = roomTimeline;
|
||||||
const unreadMsgIsLast = timeline[timeline.length - 2].getId() === readUpToId;
|
const unreadMsgIsLast = timeline[timeline.length - 2].getId() === readUpToId;
|
||||||
if (unreadMsgIsLast) {
|
if (unreadMsgIsLast) {
|
||||||
roomTimeline.markAllAsRead();
|
requestAnimationFrame(() => roomTimeline.markAllAsRead());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ class RoomTimeline extends EventEmitter {
|
||||||
this.notifications.deleteNoti(this.roomId);
|
this.notifications.deleteNoti(this.roomId);
|
||||||
if (this.timeline.length === 0) return;
|
if (this.timeline.length === 0) return;
|
||||||
const latestEvent = this.timeline[this.timeline.length - 1];
|
const latestEvent = this.timeline[this.timeline.length - 1];
|
||||||
|
if (latestEvent.isSending() || latestEvent.getId().startsWith('~')) return;
|
||||||
if (readEventId === latestEvent.getId()) return;
|
if (readEventId === latestEvent.getId()) return;
|
||||||
this.matrixClient.sendReadReceipt(latestEvent);
|
this.matrixClient.sendReadReceipt(latestEvent);
|
||||||
this.emit(cons.events.roomTimeline.MARKED_AS_READ, latestEvent);
|
this.emit(cons.events.roomTimeline.MARKED_AS_READ, latestEvent);
|
||||||
|
|
Loading…
Add table
Reference in a new issue