mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
WIP - new profile view
This commit is contained in:
parent
c757b8967f
commit
275b5bb18f
12 changed files with 568 additions and 6 deletions
40
src/app/state/hooks/userRoomProfile.ts
Normal file
40
src/app/state/hooks/userRoomProfile.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { 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
|
||||
) => void;
|
||||
export const useOpenUserRoomProfile = (): OpenCallback => {
|
||||
const setUserRoomProfile = useSetAtom(userRoomProfileAtom);
|
||||
|
||||
const open: OpenCallback = useCallback(
|
||||
(roomId, spaceId, userId, cords) => {
|
||||
setUserRoomProfile({ roomId, spaceId, userId, cords });
|
||||
},
|
||||
[setUserRoomProfile]
|
||||
);
|
||||
|
||||
return open;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue