fix(scheduler): run post-completion system actions

This commit is contained in:
NimBold
2026-07-04 17:24:16 +03:30
parent 4a322196de
commit f726b058f7
4 changed files with 186 additions and 62 deletions
+21
View File
@@ -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';
};