File size: 926 Bytes
11fcc5a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import { readonly, writable } from "svelte/store";
import type { CobaltWorkerProgress } from "$lib/types/workers";
import type { CobaltCurrentTasks, CobaltCurrentTaskItem } from "$lib/types/task-manager";
const currentTasks_ = writable<CobaltCurrentTasks>({});
export const currentTasks = readonly(currentTasks_);
export function addWorkerToQueue(workerId: string, item: CobaltCurrentTaskItem) {
currentTasks_.update(tasks => {
tasks[workerId] = item;
return tasks;
});
}
export function removeWorkerFromQueue(id: string) {
currentTasks_.update(tasks => {
delete tasks[id];
return tasks;
});
}
export function updateWorkerProgress(workerId: string, progress: CobaltWorkerProgress) {
currentTasks_.update(allTasks => {
allTasks[workerId].progress = progress;
return allTasks;
});
}
export function clearCurrentTasks() {
currentTasks_.set({});
}
|