mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
15 lines
599 B
TypeScript
15 lines
599 B
TypeScript
import { useEffect } from 'react';
|
|
import { listen } from '@tauri-apps/api/event';
|
|
import { useZipDownloadStore } from '@/features/offline/store/zipDownloadStore';
|
|
|
|
/** ZIP download progress events from Rust. */
|
|
export function useZipDownloadBridge() {
|
|
useEffect(() => {
|
|
let unlisten: (() => void) | undefined;
|
|
listen<{ id: string; bytes: number; total: number | null }>('download:zip:progress', e => {
|
|
useZipDownloadStore.getState().updateProgress(e.payload.id, e.payload.bytes, e.payload.total);
|
|
}).then(u => { unlisten = u; });
|
|
return () => { unlisten?.(); };
|
|
}, []);
|
|
}
|