commit 91956462e53b01663ab7492b43891019b2f4e98c
parent a025a2d46ad6b17a07dbd859059c072da1e99aa3
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 18 Mar 2010 07:06:38 +0000
Fixes #1635, UI glitches during syncing
New property Zotero.suppressUIUpdates is now set while processing sync data
Diffstat:
6 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js
@@ -409,7 +409,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
}
this.reload();
- if (Zotero.Sync.Server.syncInProgress) {
+ if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection);
break;
}
@@ -418,7 +418,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
case 'search':
this.reload();
- if (Zotero.Sync.Server.syncInProgress) {
+ if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection);
break;
}
@@ -730,8 +730,8 @@ Zotero.CollectionTreeView.prototype.collapseAllRows = function(treebox) {
* @param {Integer|null} libraryID Library to select, or null for local library
*/
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
- if (Zotero.Sync.Server.syncInProgress) {
- Zotero.debug("Sync in progress -- not changing library selection");
+ if (Zotero.suppressUIUpdates) {
+ Zotero.debug("UI updates suppressed -- not changing library selection");
return false;
}
diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js
@@ -362,7 +362,17 @@ Zotero.DataObjects = function (object, objectPlural, id, table) {
this.editCheck = function (obj) {
- if (!Zotero.Sync.Server.syncInProgress && !Zotero.Sync.Storage.syncInProgress && !this.isEditable(obj)) {
+ if (!Zotero.Sync.Server.updatesInProgress && !Zotero.Sync.Storage.updatesInProgress && !this.isEditable(obj)) {
+ if (Zotero.Sync.Storage.syncInProgress) {
+ try {
+ asfasf();
+ }
+ catch (e) {
+ Zotero.debug(e);
+ }
+ Components.utils.reportError("Storage sync in progress but updatesInProgress not set -- fix?");
+ return;
+ }
throw ("Cannot edit " + this._ZDO_object + " in read-only Zotero library");
}
}
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -573,7 +573,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
this.selectItem(selectItem);
}
- if (Zotero.Sync.Server.syncInProgress) {
+ if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection);
}
@@ -1112,7 +1112,8 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
*/
Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse)
{
- if (Zotero.Sync.Server.syncInProgress) {
+ // Don't change selection if UI updates are disabled (e.g., during sync)
+ if (Zotero.suppressUIUpdates) {
return;
}
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -62,6 +62,7 @@ Zotero.Sync.Storage = new function () {
this.__defineGetter__("syncInProgress", function () _syncInProgress);
+ this.__defineGetter__("updatesInProgress", function () _updatesInProgress);
this.compressionTracker = {
compressed: 0,
@@ -78,6 +79,7 @@ Zotero.Sync.Storage = new function () {
// Private properties
//
var _syncInProgress;
+ var _updatesInProgress;
var _changesMade;
var _session;
@@ -694,7 +696,9 @@ Zotero.Sync.Storage = new function () {
// and mark for updated
var file = item.getFile();
if (newFile && file.leafName != newFile.leafName) {
+ _updatesInProgress = true;
item.relinkAttachmentFile(newFile);
+ _updatesInProgress = false;
file = item.getFile();
// TODO: use an integer counter instead of mod time for change detection
var useCurrentModTime = true;
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1154,6 +1154,7 @@ Zotero.Sync.Server = new function () {
});
this.__defineGetter__("syncInProgress", function () _syncInProgress);
+ this.__defineGetter__("updatesInProgress", function () _updatesInProgress);
this.__defineGetter__("sessionIDComponent", function () {
return 'sessionid=' + _sessionID;
});
@@ -1187,6 +1188,7 @@ Zotero.Sync.Server = new function () {
var _apiVersionComponent = "version=" + this.apiVersion;
var _cachedCredentials = {};
var _syncInProgress;
+ var _updatesInProgress;
var _sessionID;
var _throttleTimeout;
var _checkTimer;
@@ -1401,9 +1403,19 @@ Zotero.Sync.Server = new function () {
// Reconcile and save updated data from server and
// prepare local data to upload
- var xmlstr = Zotero.Sync.Server.Data.processUpdatedXML(
- xml.updated, lastLocalSyncDate, syncSession, libraryID
- );
+
+ Zotero.suppressUIUpdates = true;
+ _updatesInProgress = true;
+
+ try {
+ var xmlstr = Zotero.Sync.Server.Data.processUpdatedXML(
+ xml.updated, lastLocalSyncDate, syncSession, libraryID
+ );
+ }
+ finally {
+ Zotero.suppressUIUpdates = false;
+ _updatesInProgress = false;
+ }
//Zotero.debug(xmlstr);
//throw('break');
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -146,6 +146,11 @@ var Zotero = new function(){
*/
this.__defineGetter__('locked', function () _locked);
+ /**
+ * @property {Boolean} suppressUIUpdates Don't update UI on Notifier triggers
+ */
+ this.suppressUIUpdates = false;
+
var _startupErrorHandler;
var _zoteroDirectory = false;
var _localizedStringBundle;