mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-24 09:46:29 +00:00
feat(ui): modernize desktop interactions
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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';
|
||||
Reference in New Issue
Block a user