1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-04-18 08:21:03 +00:00
rolens/frontend/src/lib/progress.js

28 lines
553 B
JavaScript
Raw Normal View History

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;
}