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

This commit is contained in:
Dan Stillman 2010-05-01 05:46:01 +00:00
parent 19e70b81b5
commit 268f37194f
3 changed files with 33 additions and 23 deletions

View file

@ -387,11 +387,12 @@
oncommand="Zotero.Sync.Server.canAutoResetClient = true; Zotero.Sync.Server.manualSyncRequired = false; Zotero.Sync.Runner.sync()">
<tooltip
id="zotero-tb-sync-tooltip"
onpopupshowing="Zotero.Sync.Runner.registerSyncStatusLabel(this.firstChild.nextSibling)"
onpopupshowing="Zotero.Sync.Runner.registerSyncStatusLabel(this.firstChild.nextSibling, this.firstChild.nextSibling.nextSibling)"
onpopuphiding="Zotero.Sync.Runner.registerSyncStatusLabel()"
noautohide="true">
<label value="&zotero.sync.button;"/>
<label id="zotero-tb-sync-status"/>
<label id="zotero-tb-sync-status" hidden="true"/>
<label id="zotero-tb-sync-last-sync"/>
</tooltip>
</toolbarbutton>
<toolbarseparator/>

View file

@ -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;
}

View file

@ -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;
}