From 268f37194ff357123017408c016ab47d09327fd4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 1 May 2010 05:46:01 +0000 Subject: [PATCH] Always show last sync time if available in sync button tooltip -- this should make it clearer when one sync has stopped and another has started --- chrome/content/zotero/overlay.xul | 5 +-- chrome/content/zotero/xpcom/sync.js | 49 +++++++++++++++----------- chrome/skin/default/zotero/overlay.css | 2 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 58a52b8662..de1299d99f 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -387,11 +387,12 @@ oncommand="Zotero.Sync.Server.canAutoResetClient = true; Zotero.Sync.Server.manualSyncRequired = false; Zotero.Sync.Runner.sync()"> diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index d5e2e39a30..339561fbba 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -492,6 +492,7 @@ Zotero.Sync.Runner = new function () { var _lastSyncStatus; var _currentSyncStatusLabel; + var _currentLastSyncLabel; var _warning = null; @@ -935,9 +936,10 @@ Zotero.Sync.Runner = new function () { * * @param {Tooltip} [label] */ - this.registerSyncStatusLabel = function (label) { - _currentSyncStatusLabel = label; - if (label) { + this.registerSyncStatusLabel = function (statusLabel, lastSyncLabel) { + _currentSyncStatusLabel = statusLabel; + _currentLastSyncLabel = lastSyncLabel; + if (_currentSyncStatusLabel) { _updateSyncStatusLabel(); } } @@ -945,26 +947,33 @@ Zotero.Sync.Runner = new function () { function _updateSyncStatusLabel() { if (_lastSyncStatus) { - var msg = _lastSyncStatus; + _currentSyncStatusLabel.value = _lastSyncStatus; + _currentSyncStatusLabel.hidden = false; } - // If no message, use last sync time else { - var lastSyncTime = Zotero.Sync.Server.lastLocalSyncTime; - if (lastSyncTime) { - var time = new Date(lastSyncTime * 1000); - var msg = Zotero.Date.toRelativeDate(time); - } - else { - var msg = Zotero.getString('sync.status.notYetSynced'); - } - - msg = Zotero.localeJoin([ - Zotero.getString('sync.status.lastSync'), - msg - ]); + _currentSyncStatusLabel.hidden = true; } - _currentSyncStatusLabel.value = msg; + // Always update last sync time + var lastSyncTime = Zotero.Sync.Server.lastLocalSyncTime; + if (lastSyncTime) { + var time = new Date(lastSyncTime * 1000); + var msg = Zotero.Date.toRelativeDate(time); + } + // Don't show "Not yet synced" if a sync is in progress + else if (_lastSyncStatus) { + _currentLastSyncLabel.hidden = true; + return; + } + else { + var msg = Zotero.getString('sync.status.notYetSynced'); + } + + _currentLastSyncLabel.value = Zotero.localeJoin([ + Zotero.getString('sync.status.lastSync'), + msg + ]); + _currentLastSyncLabel.hidden = false; } } @@ -1616,7 +1625,7 @@ Zotero.Sync.Server = new function () { if (!_sessionID) { Zotero.debug("Session ID not available -- logging in"); Zotero.Sync.Server.login(function () { - Zotero.Sync.Server.clear(); + Zotero.Sync.Server.clear(callback); }); return; } diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index b88ed1d982..40b860e78c 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -238,7 +238,7 @@ list-style-image: url(chrome://zotero/skin/arrow_rotate_animated.png); } -#zotero-tb-sync #zotero-tb-sync-status +#zotero-tb-sync-status, #zotero-tb-sync-last-sync { color: gray; }