* WIP - new profile view * render common rooms in user profile * add presence component * WIP - room user profile * temp hide profile button * show mutual rooms in spaces, rooms and direct messages categories * add message button * add option to change user powers in profile * improve ban info and option to unban * add share user button in user profile * add option to block user in user profile * improve blocked user alert body * add moderation tool in user profile * open profile view on left side in member drawer * open new user profile in all places
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { useAtomValue, useSetAtom } from 'jotai';
|
|
import { Position, RectCords } from 'folds';
|
|
import { userRoomProfileAtom, UserRoomProfileState } from '../userRoomProfile';
|
|
|
|
export const useUserRoomProfileState = (): UserRoomProfileState | undefined => {
|
|
const data = useAtomValue(userRoomProfileAtom);
|
|
|
|
return data;
|
|
};
|
|
|
|
type CloseCallback = () => void;
|
|
export const useCloseUserRoomProfile = (): CloseCallback => {
|
|
const setUserRoomProfile = useSetAtom(userRoomProfileAtom);
|
|
|
|
const close: CloseCallback = useCallback(() => {
|
|
setUserRoomProfile(undefined);
|
|
}, [setUserRoomProfile]);
|
|
|
|
return close;
|
|
};
|
|
|
|
type OpenCallback = (
|
|
roomId: string,
|
|
spaceId: string | undefined,
|
|
userId: string,
|
|
cords: RectCords,
|
|
position?: Position
|
|
) => void;
|
|
export const useOpenUserRoomProfile = (): OpenCallback => {
|
|
const setUserRoomProfile = useSetAtom(userRoomProfileAtom);
|
|
|
|
const open: OpenCallback = useCallback(
|
|
(roomId, spaceId, userId, cords, position) => {
|
|
setUserRoomProfile({ roomId, spaceId, userId, cords, position });
|
|
},
|
|
[setUserRoomProfile]
|
|
);
|
|
|
|
return open;
|
|
};
|