mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-08 02:13:24 +00:00
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import type { DownloadStatus } from '../bindings/DownloadStatus';
|
|
|
|
const STARTABLE_STATUSES: ReadonlySet<DownloadStatus> = new Set([
|
|
'ready',
|
|
'paused',
|
|
'failed',
|
|
]);
|
|
|
|
const PAUSABLE_STATUSES: ReadonlySet<DownloadStatus> = new Set([
|
|
'queued',
|
|
'downloading',
|
|
'processing',
|
|
'retrying',
|
|
]);
|
|
|
|
const REDOWNLOADABLE_STATUSES: ReadonlySet<DownloadStatus> = new Set([
|
|
'completed',
|
|
'failed',
|
|
'paused',
|
|
]);
|
|
|
|
export const canStartDownload = (status: DownloadStatus): boolean =>
|
|
STARTABLE_STATUSES.has(status);
|
|
|
|
export const canPauseDownload = (status: DownloadStatus): boolean =>
|
|
PAUSABLE_STATUSES.has(status);
|
|
|
|
export const canRedownload = (status: DownloadStatus): boolean =>
|
|
REDOWNLOADABLE_STATUSES.has(status);
|
|
|
|
export const startActionLabel = (status: DownloadStatus): 'Start' | 'Resume' =>
|
|
status === 'ready' || status === 'failed' ? 'Start' : 'Resume';
|
|
|
|
export const isTransferLocked = (status: DownloadStatus): boolean =>
|
|
status === 'downloading' || status === 'processing' || status === 'retrying';
|
|
|
|
export const isIdentityLocked = (status: DownloadStatus): boolean =>
|
|
isTransferLocked(status) || status === 'completed';
|