Files
workavia-drive/tdrive/frontend/src/app/features/drive/hooks/use-drive-realtime.tsx
T
Romaric Mourgues 0ff1cc97d4 Clean frontend files
2023-04-18 11:22:14 +02:00

18 lines
570 B
TypeScript

import { useRealtimeRoom } from '@features/global/hooks/use-realtime';
import { useDriveActions } from './use-drive-actions';
import { useDriveItem } from './use-drive-item';
export const useDriveRealtime = (id: string) => {
const { refresh } = useDriveActions();
const { websockets } = useDriveItem(id);
const room = websockets?.[0];
useRealtimeRoom(room as { room: string; token: string }, 'useDriveRealtime-' + id, () => {
refresh(id);
});
};
export const DriveRealtimeObject = ({ id }: { id: string }) => {
useDriveRealtime(id);
return <></>;
};