mirror of
https://github.com/wukko/cobalt.git
synced 2025-05-10 10:44:27 +02:00
web/ProcessingQueueItem: don't show size if size is 0, refactor
This commit is contained in:
parent
c5d5ed161d
commit
a86c552183
@ -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>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user