add missing comparator in unread rooms hook
This commit is contained in:
parent
ccc29ae166
commit
21bc1521c9
1 changed files with 9 additions and 1 deletions
|
|
@ -4,6 +4,14 @@ import { selectAtom } from 'jotai/utils';
|
|||
import { unreadRoomsAtom } from '../room/roomToUnread';
|
||||
import { useClient } from '../../hooks/useClient';
|
||||
|
||||
const compareUnread = (u1: Set<string>, u2: Set<string>): boolean => {
|
||||
if (u1.size !== u2.size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return [...u1].every((value) => u2.has(value));
|
||||
};
|
||||
|
||||
export const useRoomsUnread = (
|
||||
rooms: string[],
|
||||
unreadRooms: typeof unreadRoomsAtom
|
||||
|
|
@ -18,7 +26,7 @@ export const useRoomsUnread = (
|
|||
[rooms, ct]
|
||||
);
|
||||
|
||||
return useAtomValue(selectAtom(unreadRooms, selector));
|
||||
return useAtomValue(selectAtom(unreadRooms, selector, compareUnread));
|
||||
};
|
||||
|
||||
export const useRoomUnread = (roomId: string, unreadRooms: typeof unreadRoomsAtom): boolean => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue