Fix read receipt count

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2021-12-17 17:22:38 +05:30
parent 630dbee817
commit 9c12e11375
2 changed files with 14 additions and 11 deletions

View file

@ -438,7 +438,7 @@ const MessageOptions = React.memo(({
<MenuHeader>Options</MenuHeader> <MenuHeader>Options</MenuHeader>
<MenuItem <MenuItem
iconSrc={TickMarkIC} iconSrc={TickMarkIC}
onClick={() => openReadReceipts(roomId, roomTimeline.getEventReaders(eventId))} onClick={() => openReadReceipts(roomId, roomTimeline.getEventReaders(mEvent))}
> >
Read receipts Read receipts
</MenuItem> </MenuItem>

View file

@ -247,23 +247,26 @@ class RoomTimeline extends EventEmitter {
getLiveReaders() { getLiveReaders() {
const lastEvent = this.timeline[this.timeline.length - 1]; const lastEvent = this.timeline[this.timeline.length - 1];
const liveEvents = this.liveTimeline.getEvents(); const liveEvents = this.liveTimeline.getEvents();
const lastLiveEvent = liveEvents[liveEvents.length - 1];
let readers = []; const readers = [];
if (lastEvent) readers = this.room.getUsersReadUpTo(lastEvent);
if (lastLiveEvent !== lastEvent) { for (let i = liveEvents.length - 1; i >= 0; i -= 1) {
readers.splice(readers.length, 0, ...this.room.getUsersReadUpTo(lastLiveEvent)); readers.splice(readers.length, 0, ...this.room.getUsersReadUpTo(liveEvents[i]));
if (lastEvent === liveEvents[i]) break;
} }
return [...new Set(readers)]; return [...new Set(readers)];
} }
getEventReaders(eventId) { getEventReaders(mEvent) {
const liveEvents = this.liveTimeline.getEvents();
const readers = []; const readers = [];
let eventIndex = this.getEventIndex(eventId);
if (eventIndex < 0) return this.getLiveReaders(); for (let i = liveEvents.length - 1; i >= 0; i -= 1) {
for (; eventIndex < this.timeline.length; eventIndex += 1) { readers.splice(readers.length, 0, ...this.room.getUsersReadUpTo(liveEvents[i]));
readers.splice(readers.length, 0, ...this.room.getUsersReadUpTo(this.timeline[eventIndex])); if (mEvent === liveEvents[i]) break;
} }
return [...new Set(readers)]; return [...new Set(readers)];
} }