closes #1598, Possible to click Insert Citation twice

When the user attempts to access Integration functionality while a request is still in progress, we now bring Firefox/Zotero to the foreground.
This commit is contained in:
Simon Kornblith 2010-06-17 06:38:03 +00:00
parent 6d4d953859
commit 112b6d22e8

View file

@ -31,6 +31,7 @@ const DATA_VERSION = 3;
Zotero.Integration = new function() {
var _fifoFile = null;
var _osascriptFile;
var _inProgress = false;
this.sessions = {};
@ -156,6 +157,13 @@ Zotero.Integration = new function() {
* Executes an integration command.
*/
this.execCommand = function execCommand(agent, command) {
if(_inProgress) {
Zotero.Integration.activate();
Zotero.debug("Integration: Request already in progress; not executing "+agent+" "+command);
return;
}
_inProgress = true;
// Try to load the appropriate Zotero component; otherwise display an error using the alert
// service
try {
@ -164,6 +172,7 @@ Zotero.Integration = new function() {
var application = Components.classes[componentClass]
.getService(Components.interfaces.zoteroIntegrationApplication);
} catch(e) {
_inProgress = false;
Zotero.Integration.activate();
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
@ -176,6 +185,7 @@ Zotero.Integration = new function() {
try {
var integration = new Zotero.Integration.Document(application);
} catch(e) {
_inProgress = false;
Zotero.Integration.activate();
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
@ -228,6 +238,7 @@ Zotero.Integration = new function() {
}
}
} finally {
_inProgress = false;
integration.cleanup();
}
}