From 0f1687f1c7b50635e2908e5cce4bb88d8a359a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Fri, 10 Aug 2018 11:00:07 +0300 Subject: [PATCH] Fix invalid document citation style recovery. Closes #1543 --- .../content/zotero/xpcom/connector/server_connector.js | 2 +- chrome/content/zotero/xpcom/integration.js | 10 ++++++++-- chrome/content/zotero/xpcom/style.js | 10 ++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/connector/server_connector.js b/chrome/content/zotero/xpcom/connector/server_connector.js index 24774b7b50..0313fe1b5d 100644 --- a/chrome/content/zotero/xpcom/connector/server_connector.js +++ b/chrome/content/zotero/xpcom/connector/server_connector.js @@ -1030,7 +1030,7 @@ Zotero.Server.Connector.InstallStyle.prototype = { init: Zotero.Promise.coroutine(function* (requestData) { try { - var styleName = yield Zotero.Styles.install( + var { styleName, styleID } = yield Zotero.Styles.install( requestData.data, requestData.query.origin || null, true ); } catch (e) { diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 00f969809d..7293c14ad0 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -448,9 +448,10 @@ Zotero.Integration = new function() { let installed = false; try { - await Zotero.Styles.install( + let { styleTitle, styleID } = await Zotero.Styles.install( {url: data.style.styleID}, data.style.styleID, true ); + data.style.styleID = styleID; installed = true; } catch (e) { @@ -464,10 +465,15 @@ Zotero.Integration = new function() { } if (installed) { await session.setData(data, true); + } else { + await session.setDocPrefs(); } + } else { + await session.setDocPrefs(); } + } else { + await session.setDocPrefs(); } - await session.setDocPrefs(); } else { throw e; } diff --git a/chrome/content/zotero/xpcom/style.js b/chrome/content/zotero/xpcom/style.js index 5feee4ea41..e769e21521 100644 --- a/chrome/content/zotero/xpcom/style.js +++ b/chrome/content/zotero/xpcom/style.js @@ -279,7 +279,6 @@ Zotero.Styles = new function() { * @param {Boolean} [silent=false] Skip prompts */ this.install = Zotero.Promise.coroutine(function* (style, origin, silent=false) { - var styleTitle; var warnDeprecated; if (style instanceof Components.interfaces.nsIFile) { warnDeprecated = true; @@ -299,7 +298,7 @@ Zotero.Styles = new function() { else if (style.url) { style.string = yield Zotero.File.getContentsFromURLAsync(style.url); } - styleTitle = yield _install(style.string, origin, false, silent); + var { styleTitle, styleID } = yield _install(style.string, origin, false, silent); } catch (error) { // Unless user cancelled, show an alert with the error @@ -321,7 +320,7 @@ Zotero.Styles = new function() { } } } - return styleTitle; + return { styleTitle, styleID }; }); /** @@ -503,7 +502,10 @@ Zotero.Styles = new function() { yield win.Zotero_Preferences.Cite.refreshStylesList(styleID); } } - return existingTitle || title; + return { + styleTitle: existingTitle || title, + styleID: styleID + }; }); /**