Fixes #1635, UI glitches during syncing

New property Zotero.suppressUIUpdates is now set while processing sync data
This commit is contained in:
Dan Stillman 2010-03-18 07:06:38 +00:00
parent a025a2d46a
commit 91956462e5
6 changed files with 42 additions and 10 deletions

View File

@ -409,7 +409,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
} }
this.reload(); this.reload();
if (Zotero.Sync.Server.syncInProgress) { if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
break; break;
} }
@ -418,7 +418,7 @@ Zotero.CollectionTreeView.prototype.notify = function(action, type, ids)
case 'search': case 'search':
this.reload(); this.reload();
if (Zotero.Sync.Server.syncInProgress) { if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
break; break;
} }
@ -730,8 +730,8 @@ Zotero.CollectionTreeView.prototype.collapseAllRows = function(treebox) {
* @param {Integer|null} libraryID Library to select, or null for local library * @param {Integer|null} libraryID Library to select, or null for local library
*/ */
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) { Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
if (Zotero.Sync.Server.syncInProgress) { if (Zotero.suppressUIUpdates) {
Zotero.debug("Sync in progress -- not changing library selection"); Zotero.debug("UI updates suppressed -- not changing library selection");
return false; return false;
} }

View File

@ -362,7 +362,17 @@ Zotero.DataObjects = function (object, objectPlural, id, table) {
this.editCheck = function (obj) { 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"); throw ("Cannot edit " + this._ZDO_object + " in read-only Zotero library");
} }
} }

View File

@ -573,7 +573,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
this.selectItem(selectItem); this.selectItem(selectItem);
} }
if (Zotero.Sync.Server.syncInProgress) { if (Zotero.suppressUIUpdates) {
this.rememberSelection(savedSelection); this.rememberSelection(savedSelection);
} }
@ -1112,7 +1112,8 @@ Zotero.ItemTreeView.prototype.sort = function(itemID)
*/ */
Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse) 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; return;
} }

View File

@ -62,6 +62,7 @@ Zotero.Sync.Storage = new function () {
this.__defineGetter__("syncInProgress", function () _syncInProgress); this.__defineGetter__("syncInProgress", function () _syncInProgress);
this.__defineGetter__("updatesInProgress", function () _updatesInProgress);
this.compressionTracker = { this.compressionTracker = {
compressed: 0, compressed: 0,
@ -78,6 +79,7 @@ Zotero.Sync.Storage = new function () {
// Private properties // Private properties
// //
var _syncInProgress; var _syncInProgress;
var _updatesInProgress;
var _changesMade; var _changesMade;
var _session; var _session;
@ -694,7 +696,9 @@ Zotero.Sync.Storage = new function () {
// and mark for updated // and mark for updated
var file = item.getFile(); var file = item.getFile();
if (newFile && file.leafName != newFile.leafName) { if (newFile && file.leafName != newFile.leafName) {
_updatesInProgress = true;
item.relinkAttachmentFile(newFile); item.relinkAttachmentFile(newFile);
_updatesInProgress = false;
file = item.getFile(); file = item.getFile();
// TODO: use an integer counter instead of mod time for change detection // TODO: use an integer counter instead of mod time for change detection
var useCurrentModTime = true; var useCurrentModTime = true;

View File

@ -1154,6 +1154,7 @@ Zotero.Sync.Server = new function () {
}); });
this.__defineGetter__("syncInProgress", function () _syncInProgress); this.__defineGetter__("syncInProgress", function () _syncInProgress);
this.__defineGetter__("updatesInProgress", function () _updatesInProgress);
this.__defineGetter__("sessionIDComponent", function () { this.__defineGetter__("sessionIDComponent", function () {
return 'sessionid=' + _sessionID; return 'sessionid=' + _sessionID;
}); });
@ -1187,6 +1188,7 @@ Zotero.Sync.Server = new function () {
var _apiVersionComponent = "version=" + this.apiVersion; var _apiVersionComponent = "version=" + this.apiVersion;
var _cachedCredentials = {}; var _cachedCredentials = {};
var _syncInProgress; var _syncInProgress;
var _updatesInProgress;
var _sessionID; var _sessionID;
var _throttleTimeout; var _throttleTimeout;
var _checkTimer; var _checkTimer;
@ -1401,9 +1403,19 @@ Zotero.Sync.Server = new function () {
// Reconcile and save updated data from server and // Reconcile and save updated data from server and
// prepare local data to upload // 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); //Zotero.debug(xmlstr);
//throw('break'); //throw('break');

View File

@ -146,6 +146,11 @@ var Zotero = new function(){
*/ */
this.__defineGetter__('locked', function () _locked); this.__defineGetter__('locked', function () _locked);
/**
* @property {Boolean} suppressUIUpdates Don't update UI on Notifier triggers
*/
this.suppressUIUpdates = false;
var _startupErrorHandler; var _startupErrorHandler;
var _zoteroDirectory = false; var _zoteroDirectory = false;
var _localizedStringBundle; var _localizedStringBundle;