web/queue: add remuxing progress & general improvements

and a bunch of other stuff:
- size and percentage in queue
- indeterminate progress bar
- if libav wasm freezes, the worker kill itself
- cleaner states
- cleaner props
This commit is contained in:
wukko
2025-01-25 01:25:53 +06:00
parent c4c47bdc27
commit 44a99bdb3a
12 changed files with 117 additions and 53 deletions

View File

@@ -10,9 +10,9 @@ const currentTasks = readable<CobaltCurrentTasks>(
(_, _update) => { update = _update }
);
export function addWorkerToQueue(item: CobaltCurrentTaskItem) {
export function addWorkerToQueue(workerId: string, item: CobaltCurrentTaskItem) {
update(tasks => {
tasks[item.id] = item;
tasks[workerId] = item;
return tasks;
});
}
@@ -24,10 +24,10 @@ export function removeWorkerFromQueue(id: string) {
});
}
export function updateWorkerProgress(id: string, progress: CobaltWorkerProgress) {
update(tasks => {
tasks[id].progress = progress;
return tasks;
export function updateWorkerProgress(workerId: string, progress: CobaltWorkerProgress) {
update(allTasks => {
allTasks[workerId].progress = progress;
return allTasks;
});
}

View File

@@ -51,13 +51,13 @@ export function itemDone(id: string, workerId: string, file: File) {
checkTasks();
}
export function itemRunning(id: string, step: number) {
export function itemRunning(id: string, workerId: string) {
update(queueData => {
if (queueData[id]) {
queueData[id] = {
...queueData[id],
state: "running",
currentStep: step,
runningWorker: workerId,
}
}
return queueData;
@@ -68,6 +68,10 @@ export function itemRunning(id: string, step: number) {
export function removeItem(id: string) {
update(queueData => {
for (const worker in queueData[id].pipeline) {
removeWorkerFromQueue(queueData[id].pipeline[worker].workerId);
}
delete queueData[id];
return queueData;
});