web/ProcessingQueueItem: don't show size if size is 0, refactor

This commit is contained in:
wukko 2025-04-30 21:31:35 +06:00
parent c5d5ed161d
commit a86c552183
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2

View File

@ -53,26 +53,29 @@
}); });
$: progress = runningWorker?.progress; $: progress = runningWorker?.progress;
$: size = formatFileSize(runningWorker?.progress?.size);
type StatusText = { type StatusText = {
info: CobaltQueueItem; info: CobaltQueueItem;
runningWorker: CobaltCurrentTaskItem | undefined; runningWorker: CobaltCurrentTaskItem | undefined;
progress: CobaltWorkerProgress | undefined; progress: CobaltWorkerProgress | undefined;
size: string;
retrying: boolean; retrying: boolean;
}; };
const generateStatusText = ({ info, runningWorker, progress, retrying, size }: StatusText) => { const generateStatusText = ({ info, runningWorker, progress, retrying }: StatusText) => {
switch (info.state) { switch (info.state) {
case "running": case "running":
if (runningWorker) { if (runningWorker) {
const running = $t(`queue.state.running.${runningWorker.type}`); const running = $t(`queue.state.running.${runningWorker.type}`);
const formattedSize = formatFileSize(progress?.size);
if (progress && progress.percentage) { if (progress && progress.percentage) {
return `${running}: ${Math.ceil(progress.percentage)}%, ${size}`; return `${running}: ${Math.ceil(progress.percentage)}%, ${formattedSize}`;
} }
else if (runningWorker && progress && size) { else if (runningWorker && progress) {
return `${running}: ${size}`; if (progress.size > 0) {
return `${running}: ${formattedSize}`;
}
return running;
} }
else if (runningWorker?.type) { else if (runningWorker?.type) {
const starting = $t(`queue.state.starting.${runningWorker.type}`); const starting = $t(`queue.state.starting.${runningWorker.type}`);
@ -107,7 +110,6 @@
runningWorker, runningWorker,
progress, progress,
retrying, retrying,
size,
}); });
</script> </script>