Add Zotero.startupSyncPromise

Resolves after initial auto-sync completes or after the initial
auto-sync would run if disabled
This commit is contained in:
Dan Stillman 2025-12-29 15:52:26 -05:00
parent 4d7a099c32
commit a5843d8e2d
2 changed files with 12 additions and 1 deletions

View file

@ -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 = [

View file

@ -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
//