From 3f911faa07b067cbb77b207692c622b0d6a4d57a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 3 Jul 2009 22:40:50 +0000 Subject: [PATCH] Add "Full Sync" option to Zotero prefs --- .../content/zotero/preferences/preferences.js | 39 +++++++++++++++++-- .../zotero/preferences/preferences.xul | 14 +++++-- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index ffc58eeef..577283832 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -354,7 +354,7 @@ function handleSyncReset(action) { var index = pr.confirmEx( // TODO: localize Zotero.getString('general.warning'), - "All item data belonging to user '" + account + "' on the Zotero server " + "All data belonging to user '" + account + "' on the Zotero server " + "will be erased and replaced with data from this copy of Zotero.", buttonFlags, "Replace Server Data", @@ -368,8 +368,7 @@ function handleSyncReset(action) { Zotero.Sync.Server.sync(function () { pr.alert( "Restore Completed", - "Item data on the Zotero server has been " - + "successfully restored." + "Data on the Zotero server has been successfully restored." ); }); }); @@ -382,6 +381,40 @@ function handleSyncReset(action) { break; + case 'full-sync': + var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) + + (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + + pr.BUTTON_POS_1_DEFAULT; + var index = pr.confirmEx( + // TODO: localize + Zotero.getString('general.warning'), + "The local Zotero library will be completely merged with data belonging to user '" + account + "' on the Zotero server. " + + "Any unsynced changes will appear as conflicts.\n\n" + + "This option should generally be used only for troubleshooting sync errors.", + buttonFlags, + "Sync", + null, null, null, {} + ); + + switch (index) { + case 0: + // TODO: better error handling + Zotero.Sync.Server.resetClient(); + Zotero.Sync.Server.sync(function () { + pr.alert( + "Full Sync Completed", + "The local Zotero library has been merged with data from the Zotero server." + ); + }); + break; + + // Cancel + case 1: + return; + } + + break; + default: throw ("Invalid action '" + action + "' in handleSyncReset()"); } diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul index e8ee0ae9b..22a5dc1ef 100644 --- a/chrome/content/zotero/preferences/preferences.xul +++ b/chrome/content/zotero/preferences/preferences.xul @@ -341,10 +341,18 @@ To add a new preference: - + - + + + + + + @@ -352,7 +360,7 @@ To add a new preference: -