Fix invalid document citation style recovery. Closes #1543

This commit is contained in:
Adomas Venčkauskas 2018-08-10 11:00:07 +03:00
parent 11701f68a0
commit 0f1687f1c7
3 changed files with 15 additions and 7 deletions

View file

@ -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) {

View file

@ -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;
}

View file

@ -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
};
});
/**