From 408579e6b2b0c2ee1edb008beaeadb7573dda00a Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Fri, 29 Sep 2023 10:55:16 +0200 Subject: [PATCH] FIX: Make CookText component reactive (#23709) When navigating between renewables through the Ember router, e.g. through the links in the notifications menu the body of the reviewable (rendered by the CookText component) won't update, resulting in the same post body incorrectly being shown for all subsequent reviewables. This is happening because there is no update path between the rawText attribute being passed to CookText and the computed cooked attribute, since this is being set explicitly using an async function. This PR adds the missing link between rawText and cooked by listening for didUpdate and triggering the async function. --- app/assets/javascripts/discourse/app/components/cook-text.gjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/javascripts/discourse/app/components/cook-text.gjs b/app/assets/javascripts/discourse/app/components/cook-text.gjs index 2c86d5b0ce7..fd074a24f4e 100644 --- a/app/assets/javascripts/discourse/app/components/cook-text.gjs +++ b/app/assets/javascripts/discourse/app/components/cook-text.gjs @@ -16,6 +16,7 @@ export default class CookText extends Component { {{didUpdate this.buildOneboxes this.cooked}} {{didUpdate this.resolveShortUrls this.cooked}} {{didUpdate this.calculateOffsetHeight this.cooked}} + {{didUpdate this.loadCookedText @rawText}} > {{this.cooked}} @@ -29,6 +30,7 @@ export default class CookText extends Component { this.loadCookedText(); } + @action async loadCookedText() { const cooked = await cookAsync(this.args.rawText); this.cooked = cooked;