Merge pull request #1293 from ehwarren/bugfix/1271

Ensure tabs can be closed before executing window closure
This commit is contained in:
Eugene 2019-07-24 11:14:03 +02:00 committed by GitHub
commit b6aa1f764b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -128,9 +128,8 @@ export class AppRootComponent {
})
this.hostApp.windowCloseRequest$.subscribe(async () => {
await this.app.closeAllTabs()
this.hostApp.closeWindow()
})
await this.app.closeAllTabs() && this.hostApp.closeWindow();
});
if (window['safeModeReason']) {
ngbModal.open(SafeModeModalComponent)

View File

@ -12,7 +12,6 @@ export class WindowControlsComponent {
constructor (public hostApp: HostAppService, public app: AppService) { }
async closeWindow () {
await this.app.closeAllTabs()
this.hostApp.closeWindow()
await this.app.closeAllTabs() && this.hostApp.closeWindow()
}
}

View File

@ -206,15 +206,19 @@ export class AppService {
}
}
async closeAllTabs () {
/**
* Attempts to close all tabs, returns false if one of the tabs blocked closure
*/
async closeAllTabs () : Promise<boolean> {
for (const tab of this.tabs) {
if (!await tab.canClose()) {
return
return false;
}
}
for (const tab of this.tabs) {
tab.destroy()
}
return true;
}
/** @hidden */