From a5843d8e2d9265e7b0aa490ec7c8095a5a486fcd Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 29 Dec 2025 15:52:26 -0500 Subject: [PATCH] Add `Zotero.startupSyncPromise` Resolves after initial auto-sync completes or after the initial auto-sync would run if disabled --- chrome/content/zotero/xpcom/zotero.js | 2 ++ chrome/content/zotero/zoteroPane.js | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 7bbeb0a692..dc0039528e 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -205,6 +205,8 @@ const { CommandLineOptions } = ChromeUtils.importESModule("chrome://zotero/conte this.uiReadyPromise.then(() => { Zotero.debug("User interface ready in " + (new Date() - _startupTime) + " ms"); }); + this.startupSyncDeferred = Zotero.Promise.defer(); + this.startupSyncPromise = this.startupSyncDeferred.promise; if (options) { let opts = [ diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 54d8c11511..0a59c7b583 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -862,6 +862,7 @@ var ZoteroPane = new function () { } // Auto-sync on pane open or if new account + let startupSync = false; if (Zotero.Prefs.get('sync.autoSync') || Zotero.initAutoSync) { await Zotero.proxyAuthComplete; await Zotero.uiReadyPromise; @@ -879,11 +880,19 @@ var ZoteroPane = new function () { Zotero.debug('Firefox profile access error -- skipping initial auto-sync', 4); } else { + startupSync = true; Zotero.Sync.Runner.sync({ background: true - }).then(() => Zotero.initAutoSync = false); + }) + .then(() => { + Zotero.initAutoSync = false; + Zotero.startupSyncDeferred.resolve(); + }); } } + if (!startupSync) { + Zotero.startupSyncDeferred.resolve(); + } // Set sync icon to spinning if there's an existing sync //