commit 8994961c859601bd9893c99a88037df0c30c24db
parent 331ef4ac34a5744b9019f8107c8610ca90763b02
Author: aurimasv <aurimas.dev@gmail.com>
Date: Thu, 7 Nov 2013 05:33:39 -0600
Add "Check for Update" button to error alert when DB version is newer
Diffstat:
1 file changed, 50 insertions(+), 0 deletions(-)
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -639,6 +639,56 @@ Components.utils.import("resource://gre/modules/Services.jsm");
+ Zotero.getString('startupError.zoteroVersionIsOlder.current', Zotero.version) + "\n\n"
+ Zotero.getString('general.seeForMoreInformation', kbURL);
Zotero.startupError = msg;
+ _startupErrorHandler = function() {
+ var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ var buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING)
+ + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_OK)
+ + ps.BUTTON_POS_0_DEFAULT;
+
+ var index = ps.confirmEx(null, "", Zotero.startupError, buttonFlags,
+ Zotero.getString('general.checkForUpdate'), null, null,
+ null, {});
+
+ // "Check for updates" button
+ if(index === 0) {
+ if(Zotero.isStandalone) {
+ ZoteroStandalone.checkForUpdates();
+ } else {
+ // In Firefox, show the add-on manager
+ Components.utils.import("resource://gre/modules/AddonManager.jsm");
+ AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
+ function (addon) {
+ // Disable auto-update so that the user is presented with the option
+ var initUpdateState = addon.applyBackgroundUpdates;
+ addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
+ addon.findUpdates({
+ onNoUpdateAvailable: function() {
+ ps.alert(null, '', Zotero.getString('zotero.preferences.update.upToDate'));
+ },
+ onUpdateAvailable: function() {
+ // Show available update
+ Components.classes["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Components.interfaces.nsIWindowMediator)
+ .getMostRecentWindow('navigator:browser')
+ .BrowserOpenAddonsMgr('addons://updates/available');
+ },
+ onUpdateFinished: function() {
+ // Restore add-on auto-update state, but don't fire
+ // too quickly or the update will not show in the
+ // add-on manager
+ setTimeout(function() {
+ addon.applyBackgroundUpdates = initUpdateState;
+ }, 1000);
+ }
+ },
+ AddonManager.UPDATE_WHEN_USER_REQUESTED
+ );
+ }
+ );
+ }
+ }
+ };
}
else {
Zotero.startupError = Zotero.getString('startupError.databaseUpgradeError') + "\n\n" + e;