www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit ca833f54fc9b9371e4e76e73ffb9c92a5e249705
parent e3a9c6779bc0ffea8093cbd19d67f1730325baa2
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  6 Sep 2016 02:17:20 -0400

Fix noWait translation mode (broken by e3a9c6779bc)

Diffstat:
Mchrome/content/zotero/xpcom/translation/translate.js | 40++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -1262,25 +1262,29 @@ Zotero.Translate.Base.prototype = { this.translator[0] = Zotero.Translators.get(this.translator[0]); } - // Zotero.Translators.get() returns a promise in the connectors - if (this.noWait && this.translator[0].then && !this.translator[0].isResolved()) { - throw new Error("Translator promise is not resolved in noWait mode"); - } - - Zotero.Promise.resolve(this.translator[0]) - .then(function (translator) { - this.translator[0] = translator; - var loadPromise = this._loadTranslator(translator); - if (this.noWait) { - if (!loadPromise.isResolved()) { - return Zotero.Promise.reject(new Error("Load promise is not resolved in noWait mode")); - } - this._translateTranslatorLoaded(); - } - else { - loadPromise.then(() => this._translateTranslatorLoaded()); + // Zotero.Translators.get() returns a promise in the connectors, but we don't expect it to + // otherwise + if (!this.isConnector && this.translator[0].then) { + throw new Error("Translator should not be a promise in non-connector mode"); + } + + if (this.noWait) { + var loadPromise = this._loadTranslator(this.translator[0]); + if (!loadPromise.isResolved()) { + return Zotero.Promise.reject(new Error("Load promise is not resolved in noWait mode")); } - }.bind(this)); + this._translateTranslatorLoaded(); + } + else if (this.translator[0].then) { + Zotero.Promise.resolve(this.translator[0]) + .then(function (translator) { + this.translator[0] = translator; + this._loadTranslator(translator).then(() => this._translateTranslatorLoaded()); + }.bind(this)); + } + else { + this._loadTranslator(this.translator[0]).then(() => this._translateTranslatorLoaded()); + } return deferred.promise; }),