mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-19 13:17:56 +08:00
Add a dialog before closing the page to inform user when there're still background tasks running
This commit is contained in:
parent
45e93df2eb
commit
81507b9e75
1 changed files with 11 additions and 0 deletions
|
@ -12,6 +12,17 @@ class BackgroundTask {
|
|||
private groups: Task.Group;
|
||||
constructor() {
|
||||
this.groups = {};
|
||||
window.addEventListener("beforeunload", this.onBeforeUnload.bind(this));
|
||||
}
|
||||
|
||||
private onBeforeUnload(e: BeforeUnloadEvent) {
|
||||
const message = "Background tasks are still running";
|
||||
if (Object.keys(this.groups).length !== 0) {
|
||||
e.preventDefault();
|
||||
e.returnValue = message;
|
||||
return;
|
||||
}
|
||||
delete e["returnValue"];
|
||||
}
|
||||
|
||||
dispatch<T extends Task.Callable>(groupName: string, tasks: Task.Task<T>[]) {
|
||||
|
|
Loading…
Reference in a new issue