Modify behavior on Zotero Standalone launch to account for failure
- Close Zotero pane before database is closed prior to reload, instead of waiting until reload is complete - Show an error message if Zotero Standalone is not accessible when it should be
This commit is contained in:
parent
dd8c0ecf37
commit
0b92ad0037
|
@ -146,14 +146,19 @@ var ZoteroOverlay = new function()
|
||||||
// Hide browser chrome on Zotero tab
|
// Hide browser chrome on Zotero tab
|
||||||
XULBrowserWindow.inContentWhitelist.push("chrome://zotero/content/tab.xul");
|
XULBrowserWindow.inContentWhitelist.push("chrome://zotero/content/tab.xul");
|
||||||
|
|
||||||
// Close pane if connector is enabled
|
// Close pane before reload
|
||||||
ZoteroPane_Local.addReloadListener(function() {
|
ZoteroPane_Local.addBeforeReloadListener(function(newMode) {
|
||||||
if(Zotero.isConnector) {
|
if(newMode == "connector") {
|
||||||
// save current state
|
// save current state
|
||||||
_stateBeforeReload = !zoteroPane.hidden && !zoteroPane.collapsed;
|
_stateBeforeReload = !zoteroPane.hidden && !zoteroPane.collapsed;
|
||||||
// ensure pane is closed
|
// ensure pane is closed
|
||||||
if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false, true);
|
if(!zoteroPane.collapsed) ZoteroOverlay.toggleDisplay(false, true);
|
||||||
} else {
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close pane if connector is enabled
|
||||||
|
ZoteroPane_Local.addReloadListener(function() {
|
||||||
|
if(!Zotero.isConnector) {
|
||||||
// reopen pane if it was open before
|
// reopen pane if it was open before
|
||||||
ZoteroOverlay.toggleDisplay(_stateBeforeReload, true);
|
ZoteroOverlay.toggleDisplay(_stateBeforeReload, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,6 +473,9 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Zotero.debug("Loading in connector mode");
|
Zotero.debug("Loading in connector mode");
|
||||||
Zotero.Connector_Types.init();
|
Zotero.Connector_Types.init();
|
||||||
|
|
||||||
|
// Store a startupError until we get information from Zotero Standalone
|
||||||
|
Zotero.startupError = Zotero.getString("connector.loadInProgress")
|
||||||
|
|
||||||
if(!Zotero.isFirstLoadThisSession) {
|
if(!Zotero.isFirstLoadThisSession) {
|
||||||
// We want to get a checkInitComplete message before initializing if we switched to
|
// We want to get a checkInitComplete message before initializing if we switched to
|
||||||
// connector mode because Standalone was launched
|
// connector mode because Standalone was launched
|
||||||
|
@ -496,6 +499,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
this.initComplete = function() {
|
this.initComplete = function() {
|
||||||
if(Zotero.initialized) return;
|
if(Zotero.initialized) return;
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
delete this.startupError;
|
||||||
|
|
||||||
if(Zotero.isConnector) {
|
if(Zotero.isConnector) {
|
||||||
Zotero.Repo.init();
|
Zotero.Repo.init();
|
||||||
|
|
|
@ -91,7 +91,7 @@ var ZoteroPane = new function()
|
||||||
var self = this,
|
var self = this,
|
||||||
_loaded = false, _madeVisible = false,
|
_loaded = false, _madeVisible = false,
|
||||||
titlebarcolorState, titleState, observerService,
|
titlebarcolorState, titleState, observerService,
|
||||||
_reloadFunctions = [];
|
_reloadFunctions = [], _beforeReloadFunctions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the window containing Zotero pane is open
|
* Called when the window containing Zotero pane is open
|
||||||
|
@ -128,6 +128,13 @@ var ZoteroPane = new function()
|
||||||
observerService = Components.classes["@mozilla.org/observer-service;1"]
|
observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||||
.getService(Components.interfaces.nsIObserverService);
|
.getService(Components.interfaces.nsIObserverService);
|
||||||
observerService.addObserver(_reloadObserver, "zotero-reloaded", false);
|
observerService.addObserver(_reloadObserver, "zotero-reloaded", false);
|
||||||
|
observerService.addObserver(_reloadObserver, "zotero-before-reload", false);
|
||||||
|
this.addBeforeReloadListener(function(newMode) {
|
||||||
|
if(newMode == "connector") {
|
||||||
|
ZoteroPane_Local.setItemsPaneMessage(Zotero.getString('connector.standaloneOpen'));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
this.addReloadListener(_loadPane);
|
this.addReloadListener(_loadPane);
|
||||||
|
|
||||||
// continue loading pane
|
// continue loading pane
|
||||||
|
@ -141,10 +148,7 @@ var ZoteroPane = new function()
|
||||||
function _loadPane() {
|
function _loadPane() {
|
||||||
if(!Zotero || !Zotero.initialized) return;
|
if(!Zotero || !Zotero.initialized) return;
|
||||||
|
|
||||||
if(Zotero.isConnector) {
|
if(!Zotero.isConnector) {
|
||||||
ZoteroPane_Local.setItemsPaneMessage(Zotero.getString('connector.standaloneOpen'));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
ZoteroPane_Local.clearItemsPaneMessage();
|
ZoteroPane_Local.clearItemsPaneMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4106,6 +4110,14 @@ var ZoteroPane = new function()
|
||||||
if(_reloadFunctions.indexOf(func) === -1) _reloadFunctions.push(func);
|
if(_reloadFunctions.indexOf(func) === -1) _reloadFunctions.push(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds or removes a function to be called just before Zotero is reloaded by switching into or
|
||||||
|
* out of the connector
|
||||||
|
*/
|
||||||
|
this.addBeforeReloadListener = function(/** @param {Function} **/func) {
|
||||||
|
if(_beforeReloadFunctions.indexOf(func) === -1) _beforeReloadFunctions.push(func);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements nsIObserver for Zotero reload
|
* Implements nsIObserver for Zotero reload
|
||||||
*/
|
*/
|
||||||
|
@ -4113,9 +4125,14 @@ var ZoteroPane = new function()
|
||||||
/**
|
/**
|
||||||
* Called when Zotero is reloaded (i.e., if it is switched into or out of connector mode)
|
* Called when Zotero is reloaded (i.e., if it is switched into or out of connector mode)
|
||||||
*/
|
*/
|
||||||
"observe":function() {
|
"observe":function(aSubject, aTopic, aData) {
|
||||||
Zotero.debug("Reloading Zotero pane");
|
if(aTopic == "zotero-reloaded") {
|
||||||
for each(var func in _reloadFunctions) func();
|
Zotero.debug("Reloading Zotero pane");
|
||||||
|
for each(var func in _reloadFunctions) func(aData);
|
||||||
|
} else if(aTopic == "zotero-before-reload") {
|
||||||
|
Zotero.debug("Zotero pane caught before-reload event");
|
||||||
|
for each(var func in _beforeReloadFunctions) func(aData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -944,6 +944,7 @@ standalone.updateMessage = A recommended update is available, but you do not h
|
||||||
|
|
||||||
connector.error.title = Zotero Connector Error
|
connector.error.title = Zotero Connector Error
|
||||||
connector.standaloneOpen = Your database cannot be accessed because Zotero Standalone is currently open. Please view your items in Zotero Standalone.
|
connector.standaloneOpen = Your database cannot be accessed because Zotero Standalone is currently open. Please view your items in Zotero Standalone.
|
||||||
|
connector.loadInProgress = Zotero Standalone was launched but is not accessible. If you experienced an error opening Zotero Standalone, restart Firefox.
|
||||||
|
|
||||||
firstRunGuidance.saveIcon = Zotero has found a reference on this page. Click this icon in the address bar to save the reference to your Zotero library.
|
firstRunGuidance.saveIcon = Zotero has found a reference on this page. Click this icon in the address bar to save the reference to your Zotero library.
|
||||||
firstRunGuidance.authorMenu = Zotero lets you specify editors and translators, too. You can turn an author into an editor or translator by selecting from this menu.
|
firstRunGuidance.authorMenu = Zotero lets you specify editors and translators, too. You can turn an author into an editor or translator by selecting from this menu.
|
||||||
|
|
|
@ -120,6 +120,7 @@ const xpcomFilesConnector = [
|
||||||
];
|
];
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var instanceID = (new Date()).getTime();
|
var instanceID = (new Date()).getTime();
|
||||||
var isFirstLoadThisSession = true;
|
var isFirstLoadThisSession = true;
|
||||||
|
@ -164,6 +165,7 @@ ZoteroContext.prototype = {
|
||||||
*/
|
*/
|
||||||
"switchConnectorMode":function(isConnector) {
|
"switchConnectorMode":function(isConnector) {
|
||||||
if(isConnector !== this.isConnector) {
|
if(isConnector !== this.isConnector) {
|
||||||
|
Services.obs.notifyObservers(zContext.Zotero, "zotero-before-reload", isConnector ? "connector" : "full");
|
||||||
zContext.Zotero.shutdown().then(function() {
|
zContext.Zotero.shutdown().then(function() {
|
||||||
// create a new zContext
|
// create a new zContext
|
||||||
makeZoteroContext(isConnector);
|
makeZoteroContext(isConnector);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user