Skip to content

Commit

Permalink
presenter console: close windows on document reload
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Cecchetti <[email protected]>
Change-Id: I9a42b2b772441df93b1632e1ad318a622b193153
  • Loading branch information
mcecchetti committed Dec 8, 2024
1 parent aa936df commit 80cc778
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
11 changes: 10 additions & 1 deletion browser/src/slideshow/PresenterConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class PresenterConsole {
'unload',
L.bind(this._onWindowClose, this),
);
window.addEventListener(
'beforeunload',
L.bind(this._onWindowClose, this),
);
}
this._proxyPresenter.addEventListener(
'unload',
Expand Down Expand Up @@ -1036,6 +1040,11 @@ class PresenterConsole {
if (this._proxyPresenter && !this._proxyPresenter.closed)
this._proxyPresenter.close();

window.removeEventListener(
'beforeunload',
L.bind(this._onWindowClose, this),
);

this._presenter._stopFullScreen();
}

Expand All @@ -1044,7 +1053,7 @@ class PresenterConsole {
this._presenter._slideShowWindowProxy &&
!this._presenter._slideShowWindowProxy.closed
)
this._presenter._slideShowWindowProxy.close();
this._presenter.slideshowWindowCleanUp();

this._proxyPresenter.removeEventListener(
'resize',
Expand Down
27 changes: 20 additions & 7 deletions browser/src/slideshow/SlideShowPresenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,30 @@ class SlideShowPresenter {
this._windowCloseInterval = setInterval(
function () {
if (slideShowWindow.closed) {
this.disablePauseHandler();
clearInterval(this._windowCloseInterval);
this._slideShowNavigator.quit();
this._map.uiManager.closeSnackbar();
this._slideShowCanvas = null;
this._presenterContainer = null;
this._slideShowWindowProxy = null;
this.slideshowWindowCleanUp();
}
}.bind(this),
500,
);

window.addEventListener(
'beforeunload',
this.slideshowWindowCleanUp.bind(this),
);
}

slideshowWindowCleanUp() {
this.disablePauseHandler();
clearInterval(this._windowCloseInterval);
this._slideShowNavigator.quit();
this._map.uiManager.closeSnackbar();
this._slideShowCanvas = null;
this._presenterContainer = null;
this._slideShowWindowProxy = null;
window.removeEventListener(
'beforeunload',
this.slideshowWindowCleanUp.bind(this),
);
}

/// returns true on success
Expand Down

0 comments on commit 80cc778

Please sign in to comment.