278eb78637
CRUD в редакторе, read-only окно на пульте, отдельный аудиоканал, экспорт/импорт и маппинг из Foundry. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
629 B
TypeScript
20 lines
629 B
TypeScript
import { useEffect, useState } from 'react';
|
|
|
|
import { ipcChannels } from '../../../shared/ipc/contracts';
|
|
import type { PlaylistsState } from '../../../shared/types/appPlaylists';
|
|
import { getDndApi } from '../dndApi';
|
|
|
|
const EMPTY: PlaylistsState = { playlists: [], audios: [] };
|
|
|
|
export function useAppPlaylists(): PlaylistsState {
|
|
const api = getDndApi();
|
|
const [state, setState] = useState<PlaylistsState>(EMPTY);
|
|
|
|
useEffect(() => {
|
|
void api.invoke(ipcChannels.playlists.getState, {}).then(setState);
|
|
return api.on(ipcChannels.playlists.stateChanged, (next) => setState(next));
|
|
}, [api]);
|
|
|
|
return state;
|
|
}
|