mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 13:01:24 +00:00
Pause and resume now go through one process-level control plane that survives panel/terminal close: TransferRuntime + soft latches/epochs/walk registry, soft-then-hard resume, dual-epoch-safe progress, and no-owner soft control.
29 lines
931 B
TypeScript
29 lines
931 B
TypeScript
import { useCallback, useMemo } from "react";
|
|
|
|
import type { TransferTask } from "../../domain/models";
|
|
import {
|
|
getGlobalTransferBatchEligibility,
|
|
listGloballyPausableTransferIds,
|
|
listGloballyResumableTransferIds,
|
|
} from "../../domain/sftpTransferActions";
|
|
import { sftpTransferCenterStore } from "./sftpTransferCenterStore";
|
|
|
|
export function useGlobalSftpTransferActions(tasks: readonly TransferTask[]) {
|
|
const batchEligibility = useMemo(
|
|
() => getGlobalTransferBatchEligibility(tasks),
|
|
[tasks],
|
|
);
|
|
const pauseAll = useCallback(() => {
|
|
for (const taskId of listGloballyPausableTransferIds(tasks)) {
|
|
void sftpTransferCenterStore.pause(taskId);
|
|
}
|
|
}, [tasks]);
|
|
const resumeAll = useCallback(() => {
|
|
for (const taskId of listGloballyResumableTransferIds(tasks)) {
|
|
void sftpTransferCenterStore.resume(taskId);
|
|
}
|
|
}, [tasks]);
|
|
|
|
return { batchEligibility, pauseAll, resumeAll };
|
|
}
|