Skip to content

Node.js based forum software built for the modern web

fix: app.parseAndTranslate to always return promise

Julian Lamc2650169444f
diff --git a/public/src/app.js b/public/src/app.js
index 8db1282cc8..82ddb49857 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -742,23 +742,21 @@ app.cacheBuster = null;
blockName = undefined;
}
- const execute = (resolve, reject) => {
+ return new Promise((resolve, reject) => {
require(['translator', 'benchpress'], function (translator, Benchpress) {
Benchpress.render(template, data, blockName)
.then(rendered => translator.translate(rendered))
.then(translated => translator.unescape(translated))
.then(resolve, reject);
});
- };
+ }).then((html) => {
+ html = $(html);
+ if (callback && typeof callback === 'function') {
+ setTimeout(callback, 0, html);
+ }
- if (callback) {
- execute(
- result => setTimeout(callback, 0, $(result)),
- err => console.error(err)
- );
- } else {
- return new Promise(execute).then(html => $(html));
- }
+ return html;
+ });
};
app.showCookieWarning = function () {