commit f3fd7e7a100e4ba3e8a6f95c065f2c4d2f5879cb
parent 8c48b2f806838de020069dceccee9ca4ad7b3820
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 2 Dec 2016 16:52:28 -0500
Don't load bundled files in Standalone until UI is ready
Diffstat:
3 files changed, 44 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -88,7 +88,7 @@ Zotero.Schema = new function(){
Zotero.debug('Database does not exist -- creating\n');
return _initializeSchema()
.then(function() {
- Zotero.initializationPromise
+ (Zotero.isStandalone ? Zotero.uiReadyPromise : Zotero.initializationPromise)
.then(1000)
.then(function () {
return Zotero.Schema.updateBundledFiles();
@@ -182,7 +182,9 @@ Zotero.Schema = new function(){
// Reset sync queue tries if new version
yield _checkClientVersion();
- Zotero.initializationPromise
+ // In Standalone, don't load bundled files until after UI is ready. In Firefox, load them as
+ // soon initialization is done so that translation works before the Zotero pane is opened.
+ (Zotero.isStandalone ? Zotero.uiReadyPromise : Zotero.initializationPromise)
.then(1000)
.then(function () {
return Zotero.Schema.updateBundledFiles();
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -93,10 +93,12 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
this.closing = false;
- this.initializationDeferred;
- this.initializationPromise;
this.unlockDeferred;
this.unlockPromise;
+ this.initializationDeferred;
+ this.initializationPromise;
+ this.objectInitializationDeferred;
+ this.objectInitializationPromise;
this.hiDPISuffix = "";
@@ -129,6 +131,7 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
*/
var _runningTimers = new Map();
+ var _startupTime = new Date();
// Errors that were in the console at startup
var _startupErrors = [];
// Number of errors to maintain in the recent errors buffer
@@ -146,9 +149,11 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
return false;
}
+ this.locked = true;
this.initializationDeferred = Zotero.Promise.defer();
this.initializationPromise = this.initializationDeferred.promise;
- this.locked = true;
+ this.uiReadyDeferred = Zotero.Promise.defer();
+ this.uiReadyPromise = this.uiReadyDeferred.promise;
// Add a function to Zotero.Promise to check whether a value is still defined, and if not
// to throw a specific error that's ignored by the unhandled rejection handler in
@@ -429,6 +434,14 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
}
+ this.uiIsReady = function () {
+ if (this.uiReadyPromise.isPending()) {
+ Zotero.debug("User interface ready in " + (new Date() - _startupTime) + " ms");
+ this.uiReadyDeferred.resolve();
+ }
+ };
+
+
var _addToolbarIcon = function () {
if (Zotero.isStandalone) return;
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -1138,17 +1138,24 @@ var ZoteroPane = new function()
});
+ this.tagSelectorShown = function () {
+ var collectionTreeRow = this.getCollectionTreeRow();
+ if (!collectionTreeRow) return;
+ var tagSelector = document.getElementById('zotero-tag-selector');
+ return !tagSelector.getAttribute('collapsed')
+ || tagSelector.getAttribute('collapsed') == 'false';
+ };
+
+
/*
* Set the tags scope to the items in the current view
*
* Passed to the items tree to trigger on changes
*/
this.setTagScope = Zotero.Promise.coroutine(function* () {
- var collectionTreeRow = self.getCollectionTreeRow();
- if (!collectionTreeRow) return;
+ var collectionTreeRow = this.getCollectionTreeRow();
var tagSelector = document.getElementById('zotero-tag-selector');
- if (!tagSelector.getAttribute('collapsed') ||
- tagSelector.getAttribute('collapsed') == 'false') {
+ if (this.tagSelectorShown()) {
Zotero.debug('Updating tag selector with current tags');
if (collectionTreeRow.editable) {
tagSelector.mode = 'edit';
@@ -1157,7 +1164,7 @@ var ZoteroPane = new function()
tagSelector.mode = 'view';
}
tagSelector.collectionTreeRow = collectionTreeRow;
- tagSelector.updateScope = self.setTagScope;
+ tagSelector.updateScope = () => this.setTagScope();
tagSelector.libraryID = collectionTreeRow.ref.libraryID;
tagSelector.scope = yield collectionTreeRow.getChildTags();
}
@@ -1224,7 +1231,18 @@ var ZoteroPane = new function()
Zotero.Prefs.clear('lastViewedFolder');
ZoteroPane_Local.displayErrorMessage();
};
- this.itemsView.addEventListener('load', this.setTagScope);
+ this.itemsView.addEventListener('load', () => this.setTagScope());
+ if (this.tagSelectorShown()) {
+ let tagSelector = document.getElementById('zotero-tag-selector')
+ let handler = function () {
+ tagSelector.removeEventListener('refresh', handler);
+ Zotero.uiIsReady();
+ };
+ tagSelector.addEventListener('refresh', handler);
+ }
+ else {
+ this.itemsView.addEventListener('load', () => Zotero.uiIsReady());
+ }
// If item data not yet loaded for library, load it now.
// Other data types are loaded at startup