mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-18 07:13:13 +00:00
fix(scheduler): run post-completion system actions
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { DownloadItem } from '../bindings/DownloadItem';
|
||||
import { isActiveDownloadStatus } from './downloads';
|
||||
|
||||
export type SchedulerCompletionState = 'active' | 'completed' | 'incomplete';
|
||||
|
||||
export const schedulerCompletionState = (
|
||||
downloads: DownloadItem[],
|
||||
schedulerActiveDownloadIds: string[],
|
||||
): SchedulerCompletionState => {
|
||||
const scheduledItems = schedulerActiveDownloadIds.map(id =>
|
||||
downloads.find(download => download.id === id)
|
||||
);
|
||||
|
||||
if (scheduledItems.some(item => item && isActiveDownloadStatus(item.status))) {
|
||||
return 'active';
|
||||
}
|
||||
|
||||
return scheduledItems.every(item => item?.status === 'completed')
|
||||
? 'completed'
|
||||
: 'incomplete';
|
||||
};
|
||||
Reference in New Issue
Block a user