no-bug: re-schedule live folders fetch after sleep (gh-12883)

This commit is contained in:
Slowlife
2026-03-24 05:43:21 +07:00
committed by GitHub
parent 3c52906878
commit c812a07a84
2 changed files with 42 additions and 1 deletions

View File

@@ -3,3 +3,4 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
category browser-window-delayed-startup resource:///modules/zen/ZenLiveFoldersManager.sys.mjs ZenLiveFoldersManager.init
category browser-quit-application-granted resource:///modules/zen/ZenLiveFoldersManager.sys.mjs ZenLiveFoldersManager.uninit

View File

@@ -34,7 +34,9 @@ class nsZenLiveFoldersManager {
#saveFilename = "zen-live-folders.jsonlz4";
#file = null;
#boundHandleEvent = null;
stateRestored = Promise.withResolvers();
constructor() {
this.liveFolders = new Map();
this.registry = new Map();
@@ -63,10 +65,48 @@ class nsZenLiveFoldersManager {
this.#isInitialized = true;
}
uninit() {
if (!this.#isInitialized) {
return;
}
Services.obs.removeObserver(this, "wake_notification");
if (this.#boundHandleEvent) {
lazy.ZenWindowSync.removeSyncHandler(this.#boundHandleEvent);
this.#boundHandleEvent = null;
}
for (const liveFolder of this.liveFolders.values()) {
liveFolder.stop();
}
this.registry.clear();
this.liveFolders.clear();
this.dismissedItems.clear();
this.#isInitialized = false;
}
// Event Handling
// --------------
#initEventListeners() {
lazy.ZenWindowSync.addSyncHandler(this.handleEvent.bind(this));
Services.obs.addObserver(this, "wake_notification");
this.#boundHandleEvent = this.handleEvent.bind(this);
lazy.ZenWindowSync.addSyncHandler(this.#boundHandleEvent);
}
observe(_subject, topic, _data) {
switch (topic) {
case "wake_notification": {
// Woke from sleep, re-schedule all fetch
for (const liveFolder of this.liveFolders.values()) {
liveFolder.stop();
liveFolder.start();
}
break;
}
}
}
handleEvent(aEvent) {