mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 06:09:30 +08: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 decoratorAlias from "discourse-common/utils/decorator-alias";
|
||||||
import extractValue from "discourse-common/utils/extract-value";
|
import extractValue from "discourse-common/utils/extract-value";
|
||||||
import handleDescriptor from "discourse-common/utils/handle-descriptor";
|
import handleDescriptor from "discourse-common/utils/handle-descriptor";
|
||||||
|
@ -19,13 +19,11 @@ export default function discourseComputedDecorator(...params) {
|
||||||
export function afterRender(target, name, descriptor) {
|
export function afterRender(target, name, descriptor) {
|
||||||
const originalFunction = descriptor.value;
|
const originalFunction = descriptor.value;
|
||||||
descriptor.value = function () {
|
descriptor.value = function () {
|
||||||
next(() => {
|
|
||||||
schedule("afterRender", () => {
|
schedule("afterRender", () => {
|
||||||
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
if (this.element && !this.isDestroying && !this.isDestroyed) {
|
||||||
return originalFunction.apply(this, arguments);
|
return originalFunction.apply(this, arguments);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { afterRender } from "discourse-common/utils/decorators";
|
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { cookAsync } from "discourse/lib/text";
|
import { cookAsync } from "discourse/lib/text";
|
||||||
import { loadOneboxes } from "discourse/lib/load-oneboxes";
|
import { loadOneboxes } from "discourse/lib/load-oneboxes";
|
||||||
|
@ -10,31 +9,26 @@ const CookText = Component.extend({
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
cookAsync(this.rawText).then((cooked) => {
|
cookAsync(this.rawText).then((cooked) => {
|
||||||
this.set("cooked", cooked);
|
this.set("cooked", cooked);
|
||||||
if (this.paintOneboxes) {
|
|
||||||
this._loadOneboxes();
|
|
||||||
}
|
|
||||||
this._resolveUrls();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@afterRender
|
didRender() {
|
||||||
_loadOneboxes() {
|
this._super(...arguments);
|
||||||
const refresh = false;
|
|
||||||
|
|
||||||
|
if (this.paintOneboxes) {
|
||||||
loadOneboxes(
|
loadOneboxes(
|
||||||
this.element,
|
this.element,
|
||||||
ajax,
|
ajax,
|
||||||
this.topicId,
|
this.topicId,
|
||||||
this.categoryId,
|
this.categoryId,
|
||||||
this.siteSettings.max_oneboxes_per_post,
|
this.siteSettings.max_oneboxes_per_post,
|
||||||
refresh
|
false // refresh
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
@afterRender
|
|
||||||
_resolveUrls() {
|
|
||||||
resolveAllShortUrls(ajax, this.siteSettings, this.element, this.opts);
|
resolveAllShortUrls(ajax, this.siteSettings, this.element, this.opts);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user