In one of my extentions, I had written the code below:
app.initializers.add('flarum-msemoji', (app) => {
// (...ignored some code)
if (app.forum.attribute("flarum-msemoji.disable_autocomplete") != '1') addComposerAutocomplete();
});
But then I found it failed, with console I found that when it performs, app.forum
is null.
I tried to search something relative, then found askvortsov, but there's nothing helpful.
I had to rewrite it into this:
new Promise(function (resolve) {
var id = setInterval(function () {
if (app.forum) {
if (app.forum.attribute) {
clearInterval(id);
resolve();
}
}
}, 500)
}).then(function () {
if (app.forum.attribute("flarum-msemoji.disable_autocomplete") != '1') addComposerAutocomplete();
});
It can work, but as you can see, it just seems too low. Is there any way to improve it?