mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 21:19:41 -06:00
DEV: Make @afterRender
do just that, no extra next()
(#15086)
This commit is contained in:
parent
4229e3f22c
commit
fac6cc0778
@ -1,4 +1,4 @@
|
||||
import { bind as emberBind, next, schedule } from "@ember/runloop";
|
||||
import { bind as emberBind, schedule } from "@ember/runloop";
|
||||
import decoratorAlias from "discourse-common/utils/decorator-alias";
|
||||
import extractValue from "discourse-common/utils/extract-value";
|
||||
import handleDescriptor from "discourse-common/utils/handle-descriptor";
|
||||
@ -19,12 +19,10 @@ export default function discourseComputedDecorator(...params) {
|
||||
export function afterRender(target, name, descriptor) {
|
||||
const originalFunction = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
next(() => {
|
||||
schedule("afterRender", () => {
|
||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
||||
return originalFunction.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
schedule("afterRender", () => {
|
||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
||||
return originalFunction.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Component from "@ember/component";
|
||||
import { afterRender } from "discourse-common/utils/decorators";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import { loadOneboxes } from "discourse/lib/load-oneboxes";
|
||||
@ -10,31 +9,26 @@ const CookText = Component.extend({
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
cookAsync(this.rawText).then((cooked) => {
|
||||
this.set("cooked", cooked);
|
||||
if (this.paintOneboxes) {
|
||||
this._loadOneboxes();
|
||||
}
|
||||
this._resolveUrls();
|
||||
});
|
||||
},
|
||||
|
||||
@afterRender
|
||||
_loadOneboxes() {
|
||||
const refresh = false;
|
||||
didRender() {
|
||||
this._super(...arguments);
|
||||
|
||||
loadOneboxes(
|
||||
this.element,
|
||||
ajax,
|
||||
this.topicId,
|
||||
this.categoryId,
|
||||
this.siteSettings.max_oneboxes_per_post,
|
||||
refresh
|
||||
);
|
||||
},
|
||||
if (this.paintOneboxes) {
|
||||
loadOneboxes(
|
||||
this.element,
|
||||
ajax,
|
||||
this.topicId,
|
||||
this.categoryId,
|
||||
this.siteSettings.max_oneboxes_per_post,
|
||||
false // refresh
|
||||
);
|
||||
}
|
||||
|
||||
@afterRender
|
||||
_resolveUrls() {
|
||||
resolveAllShortUrls(ajax, this.siteSettings, this.element, this.opts);
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user