Refactor ZenGlanceManager.mjs to handle quitting application when closing glance

This commit is contained in:
mr. M 2024-10-31 22:26:35 +01:00
parent 458bb54a34
commit 220c9b42a5
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB

View file

@ -19,7 +19,7 @@
document.getElementById('tabbrowser-tabpanels').addEventListener("click", this.onOverlayClick.bind(this)); document.getElementById('tabbrowser-tabpanels').addEventListener("click", this.onOverlayClick.bind(this));
window.addEventListener("beforeunload", this.onUnload.bind(this)); Services.obs.addObserver(this, "quit-application-requested");
} }
onKeyDown(event) { onKeyDown(event) {
@ -36,6 +36,14 @@
} }
} }
observe(subject, topic) {
switch (topic) {
case "quit-application-requested":
this.onUnload();
break;
}
}
onUnload() { onUnload() {
// clear everything // clear everything
if (this.#currentBrowser) { if (this.#currentBrowser) {