Fix integration transaction getting stuck when google docs tab is closed
Closes #2583
This commit is contained in:
parent
fca16d2ad5
commit
ff920de130
5 changed files with 28 additions and 12 deletions
|
@ -1163,6 +1163,7 @@ var Zotero_QuickFormat = new function () {
|
|||
accepted = true;
|
||||
io.citation.citationItems = [];
|
||||
io.accept();
|
||||
window.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -71,15 +71,16 @@ Zotero.HTTPIntegrationClient.Application.prototype = {
|
|||
this.supportsImportExport = result.supportsImportExport || this.supportsImportExport;
|
||||
this.supportsTextInsertion = result.supportsTextInsertion || this.supportsTextInsertion;
|
||||
this.processorName = result.processorName || this.processorName;
|
||||
return new Zotero.HTTPIntegrationClient.Document(result.documentID);
|
||||
return new Zotero.HTTPIntegrationClient.Document(result.documentID, this.processorName);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* See integrationTests.js
|
||||
*/
|
||||
Zotero.HTTPIntegrationClient.Document = function(documentID) {
|
||||
Zotero.HTTPIntegrationClient.Document = function(documentID, processorName) {
|
||||
this._documentID = documentID;
|
||||
this.processorName = processorName;
|
||||
};
|
||||
for (let method of ["activate", "canInsertField", "displayAlert", "getDocumentData",
|
||||
"setDocumentData", "setBibliographyStyle", "importDocument", "exportDocument",
|
||||
|
|
|
@ -64,14 +64,19 @@ Zotero.Server.Endpoints['/connector/document/respond'].prototype = {
|
|||
catch (e) {}
|
||||
if (data && data.error) {
|
||||
// Apps Script stack is a JSON object
|
||||
let error = new Error("HTTP Integration Error");
|
||||
if (typeof data.stack != "string") {
|
||||
data.stack = JSON.stringify(data.stack);
|
||||
}
|
||||
let error = data;
|
||||
if (data.error == 'Alert') {
|
||||
error = new Zotero.Exception.Alert(data.message);
|
||||
error.stack = data.stack;
|
||||
}
|
||||
else if (data.error == 'Tab Not Available Error') {
|
||||
let client = Zotero.Integration.currentDoc.processorName || 'Google Docs';
|
||||
error = new Zotero.Exception.Alert(Zotero.getString('integration.error.tabUnavailable', client));
|
||||
error.stack = data.stack;
|
||||
}
|
||||
Zotero.HTTPIntegrationClient.deferredResponse.reject(error);
|
||||
} else {
|
||||
Zotero.HTTPIntegrationClient.deferredResponse.resolve(data);
|
||||
|
|
|
@ -263,16 +263,19 @@ Zotero.Integration = new function() {
|
|||
}
|
||||
catch (e) {
|
||||
if (!(e instanceof Zotero.Exception.UserCancelled)) {
|
||||
Zotero.Integration._handleCommandError(document, session, e);
|
||||
await Zotero.Integration._handleCommandError(document, session, e);
|
||||
}
|
||||
else {
|
||||
if (session) {
|
||||
// If user cancels we should still write the currently assigned session ID
|
||||
try {
|
||||
await document.setDocumentData(session.data.serialize());
|
||||
// And any citations marked for processing (like retraction warning ignore flag changes)
|
||||
if (Object.keys(session.processIndices).length) {
|
||||
session.updateDocument(FORCE_CITATIONS_FALSE, false, false);
|
||||
}
|
||||
// Since user cancelled we can ignore if processor fails here.
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -366,10 +369,15 @@ Zotero.Integration = new function() {
|
|||
|
||||
Zotero.Utilities.Internal.activate();
|
||||
let ps = Services.prompt;
|
||||
if (e instanceof Zotero.Exception.Alert) {
|
||||
ps.alert(null, Zotero.getString('integration.error.title'), displayError);
|
||||
}
|
||||
else {
|
||||
let index = ps.confirm(null, Zotero.getString('integration.error.title'), displayError);
|
||||
if (index == 1) {
|
||||
Zotero.launchURL(supportURL);
|
||||
}
|
||||
}
|
||||
|
||||
// CiteprocRsDriverError available only if citeproc-rs is enabled
|
||||
try {
|
||||
|
|
|
@ -946,6 +946,7 @@ integration.error.macWordSBPermissionsMissing.pre2016 = If “Microsoft Word”
|
|||
integration.error.m1UpgradeOS.title = macOS Upgrade Required
|
||||
integration.error.m1UpgradeOS = Citing in Word on an Apple Silicon Mac with macOS 11.3 or earlier is not supported and may cause %S to freeze. Please upgrade to macOS 11.4 or later.
|
||||
integration.error.viewTroubleshootingInfo = Would you like to view troubleshooting instructions?
|
||||
integration.error.tabUnavailable = The integration operation cannot be completed because the %S tab is no longer unavailable.
|
||||
|
||||
integration.replace = Replace this Zotero field?
|
||||
integration.missingItem.single = The highlighted citation no longer exists in your Zotero database. Do you want to select a substitute item?
|
||||
|
|
Loading…
Reference in a new issue