2023-08-07 18:21:45 +02:00
|
|
|
import { StartProgressBar, StopProgressBar } from '$wails/go/ui/UI.js';
|
2023-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
let taskCounter = 0;
|
|
|
|
|
|
|
|
export function startProgress(taskDescription = 'Loading…') {
|
|
|
|
const taskIndex = ++taskCounter;
|
2023-05-27 17:52:51 +02:00
|
|
|
let started = false;
|
|
|
|
|
|
|
|
const debouncer = setTimeout(() => {
|
|
|
|
StartProgressBar(taskIndex, taskDescription);
|
|
|
|
started = true;
|
|
|
|
}, 150);
|
2023-05-26 17:21:39 +02:00
|
|
|
|
|
|
|
const task = {
|
|
|
|
id: taskIndex,
|
|
|
|
description: taskDescription,
|
2023-05-27 17:52:51 +02:00
|
|
|
|
|
|
|
end: () => {
|
|
|
|
clearTimeout(debouncer);
|
|
|
|
if (started) {
|
|
|
|
StopProgressBar(taskIndex);
|
|
|
|
}
|
|
|
|
},
|
2023-05-26 17:21:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return task;
|
|
|
|
}
|