mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-15 03:30:29 +03:00
* optimize room typing members hook * remove unused code - WIP * remove old code from initMatrix * remove twemojify function * remove old sanitize util * delete old markdown util * delete Math atom component * uninstall unused dependencies * remove old notification system * decrypt message in inbox notification center and fix refresh in background * improve notification --------- Co-authored-by: Krishan <33421343+kfiven@users.noreply.github.com>
26 lines
843 B
TypeScript
26 lines
843 B
TypeScript
import { useAtomValue } from 'jotai';
|
|
import { selectAtom } from 'jotai/utils';
|
|
import { useCallback } from 'react';
|
|
import {
|
|
IRoomIdToTypingMembers,
|
|
TypingReceipt,
|
|
roomIdToTypingMembersAtom,
|
|
} from '../state/typingMembers';
|
|
|
|
const typingReceiptEqual = (a: TypingReceipt, b: TypingReceipt): boolean =>
|
|
a.userId === b.userId && a.ts === b.ts;
|
|
|
|
const equalTypingMembers = (x: TypingReceipt[], y: TypingReceipt[]): boolean => {
|
|
if (x.length !== y.length) return false;
|
|
return x.every((a, i) => typingReceiptEqual(a, y[i]));
|
|
};
|
|
|
|
export const useRoomTypingMember = (roomId: string) => {
|
|
const selector = useCallback(
|
|
(roomToTyping: IRoomIdToTypingMembers) => roomToTyping.get(roomId) ?? [],
|
|
[roomId]
|
|
);
|
|
|
|
const typing = useAtomValue(selectAtom(roomIdToTypingMembersAtom, selector, equalTypingMembers));
|
|
return typing;
|
|
};
|