mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-22 08:56:44 +00:00
feat(torrent): complete lifecycle controls and diagnostics
- add durable Torrent telemetry, availability, sharing, relocation, and web-seed workflows\n- fence queue ownership, lifecycle recovery, persistence, and native control races\n- add localized UI, generated bindings, regression coverage, and smoke validation
This commit is contained in:
@@ -3,12 +3,16 @@ import type { DownloadProgressEvent } from '../bindings/DownloadProgressEvent';
|
||||
|
||||
interface DownloadProgressState {
|
||||
progressMap: Record<string, DownloadProgressEvent>;
|
||||
moveProgressMap: Record<string, number>;
|
||||
updateDownloadProgress: (id: string, payload: DownloadProgressEvent) => void;
|
||||
clearDownloadProgress: (id: string) => void;
|
||||
setMoveProgress: (id: string, fraction: number) => void;
|
||||
clearMoveProgress: (id: string) => void;
|
||||
}
|
||||
|
||||
export const useDownloadProgressStore = create<DownloadProgressState>((set) => ({
|
||||
progressMap: {},
|
||||
moveProgressMap: {},
|
||||
updateDownloadProgress: (id, payload) =>
|
||||
set((state) => ({
|
||||
progressMap: {
|
||||
@@ -18,9 +22,22 @@ export const useDownloadProgressStore = create<DownloadProgressState>((set) => (
|
||||
})),
|
||||
clearDownloadProgress: (id) =>
|
||||
set((state) => {
|
||||
if (!(id in state.progressMap)) return state;
|
||||
if (!(id in state.progressMap) && !(id in state.moveProgressMap)) return state;
|
||||
const next = { ...state.progressMap };
|
||||
delete next[id];
|
||||
return { progressMap: next };
|
||||
const nextMove = { ...state.moveProgressMap };
|
||||
delete nextMove[id];
|
||||
return { progressMap: next, moveProgressMap: nextMove };
|
||||
}),
|
||||
setMoveProgress: (id, fraction) =>
|
||||
set((state) => ({
|
||||
moveProgressMap: { ...state.moveProgressMap, [id]: fraction }
|
||||
})),
|
||||
clearMoveProgress: (id) =>
|
||||
set((state) => {
|
||||
if (!(id in state.moveProgressMap)) return state;
|
||||
const next = { ...state.moveProgressMap };
|
||||
delete next[id];
|
||||
return { moveProgressMap: next };
|
||||
}),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user