fix wrong following member count on message sent (#1464)
This commit is contained in:
parent
144cf71368
commit
03af183fb3
1 changed files with 21 additions and 0 deletions
|
@ -3,6 +3,11 @@ import { useEffect, useState } from 'react';
|
|||
|
||||
const getEventReaders = (room: Room, evtId?: string) => {
|
||||
if (!evtId) return [];
|
||||
|
||||
// if eventId is locally generated
|
||||
// we don't have read receipt for it yet
|
||||
if (!evtId.startsWith('$')) return [];
|
||||
|
||||
const liveEvents = room.getLiveTimeline().getEvents();
|
||||
const userIds: string[] = [];
|
||||
|
||||
|
@ -25,9 +30,25 @@ export const useRoomEventReaders = (room: Room, eventId?: string): string[] => {
|
|||
setReaders(getEventReaders(room, eventId));
|
||||
};
|
||||
|
||||
const handleLocalEcho: RoomEventHandlerMap[RoomEvent.LocalEchoUpdated] = (
|
||||
event,
|
||||
r,
|
||||
oldEventId
|
||||
) => {
|
||||
// update members on local event id replaced
|
||||
// with server generated id
|
||||
if (r.roomId !== room.roomId || !oldEventId) return;
|
||||
if (oldEventId.startsWith('$')) return;
|
||||
if (oldEventId !== eventId) return;
|
||||
|
||||
setReaders(getEventReaders(room, event.getId()));
|
||||
};
|
||||
|
||||
room.on(RoomEvent.Receipt, handleReceipt);
|
||||
room.on(RoomEvent.LocalEchoUpdated, handleLocalEcho);
|
||||
return () => {
|
||||
room.removeListener(RoomEvent.Receipt, handleReceipt);
|
||||
room.removeListener(RoomEvent.LocalEchoUpdated, handleLocalEcho);
|
||||
};
|
||||
}, [room, eventId]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue