mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 23:02:45 +08:00
FIX: CookText may be gone before promise resolves (#10097)
* FIX: CookText may be gone before promise resolves Bug introduced in293467a37a
. * DEV: Drop the window.requireModule in cook-text It was introduced in 2017 in232311aa8c
but doesn't seem to be necessary anymore.
This commit is contained in:
parent
64ce12a758
commit
3b51e05de2
|
@ -1,7 +1,7 @@
|
|||
import { next } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { resolveAllShortUrls } from "pretty-text/upload-short-url";
|
||||
|
||||
const CookText = Component.extend({
|
||||
cooked: null,
|
||||
|
@ -10,13 +10,10 @@ const CookText = Component.extend({
|
|||
this._super(...arguments);
|
||||
cookAsync(this.rawText).then(cooked => {
|
||||
this.set("cooked", cooked);
|
||||
// no choice but to defer this cause
|
||||
// pretty text may only be loaded now
|
||||
next(() =>
|
||||
window
|
||||
.requireModule("pretty-text/upload-short-url")
|
||||
.resolveAllShortUrls(ajax, this.siteSettings, this.element)
|
||||
);
|
||||
|
||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
||||
return resolveAllShortUrls(ajax, this.siteSettings, this.element);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user