mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-09 16:50:28 +03:00
Hide existing messages from ignored users (#2236)
* add ignored users hook * remove messages from timeline for ignored users
This commit is contained in:
parent
36a8ce5561
commit
5fbd0c13db
3 changed files with 34 additions and 16 deletions
18
src/app/hooks/useIgnoredUsers.ts
Normal file
18
src/app/hooks/useIgnoredUsers.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { useMemo } from 'react';
|
||||
import { useAccountData } from './useAccountData';
|
||||
import { AccountDataEvent } from '../../types/matrix/accountData';
|
||||
|
||||
export type IgnoredUserListContent = {
|
||||
ignored_users?: Record<string, object>;
|
||||
};
|
||||
|
||||
export const useIgnoredUsers = (): string[] => {
|
||||
const ignoredUserListEvt = useAccountData(AccountDataEvent.IgnoredUserList);
|
||||
const ignoredUsers = useMemo(() => {
|
||||
const ignoredUsersRecord =
|
||||
ignoredUserListEvt?.getContent<IgnoredUserListContent>().ignored_users ?? {};
|
||||
return Object.keys(ignoredUsersRecord);
|
||||
}, [ignoredUserListEvt]);
|
||||
|
||||
return ignoredUsers;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue