A platform for community discussion. Free, open, simple.
DEV: Make `@afterRender` do just that, no extra `next()` (#15086)
Jarek Radoszfac6cc0778e6
diff --git a/app/assets/javascripts/discourse-common/addon/utils/decorators.js b/app/assets/javascripts/discourse-common/addon/utils/decorators.jsindex a7f1d0a53d3..3439a4239fb 100644--- a/app/assets/javascripts/discourse-common/addon/utils/decorators.js+++ b/app/assets/javascripts/discourse-common/addon/utils/decorators.js@@ -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);+ }});};}diff --git a/app/assets/javascripts/discourse/app/components/cook-text.js b/app/assets/javascripts/discourse/app/components/cook-text.jsindex 87765cc40bd..a45339bd406 100644--- a/app/assets/javascripts/discourse/app/components/cook-text.js+++ b/app/assets/javascripts/discourse/app/components/cook-text.js@@ -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;-- loadOneboxes(- this.element,- ajax,- this.topicId,- this.categoryId,- this.siteSettings.max_oneboxes_per_post,- refresh- );- },+ didRender() {+ this._super(...arguments);++ 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);},});