From 35084d308988a94d5ce1dbdc15742afb560a521d Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 14 Feb 2025 09:46:32 +0000 Subject: [PATCH] DEV: Refactor PostList cooked HTML rendering (#31307) - Remove JQuery - Move decoration into `components/post-item`, instead of managing it from the top-level user-stream component - Use new `DecoratedHtml` component --- .../app/components/post-list/item/index.gjs | 23 +++++-- .../discourse/app/components/user-stream.gjs | 65 ++++--------------- .../javascripts/discourse/app/models/post.js | 2 + .../acceptance/user-drafts-stream-test.js | 2 +- 4 files changed, 35 insertions(+), 57 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/post-list/item/index.gjs b/app/assets/javascripts/discourse/app/components/post-list/item/index.gjs index d616e025055..f8a2c0f6aa0 100644 --- a/app/assets/javascripts/discourse/app/components/post-list/item/index.gjs +++ b/app/assets/javascripts/discourse/app/components/post-list/item/index.gjs @@ -2,18 +2,22 @@ import Component from "@glimmer/component"; import { fn } from "@ember/helper"; import { service } from "@ember/service"; import { htmlSafe } from "@ember/template"; +import { or } from "truth-helpers"; import DButton from "discourse/components/d-button"; +import DecoratedHtml from "discourse/components/decorated-html"; import ExpandPost from "discourse/components/expand-post"; import PostListItemDetails from "discourse/components/post-list/item/details"; import avatar from "discourse/helpers/avatar"; import concatClass from "discourse/helpers/concat-class"; import icon from "discourse/helpers/d-icon"; +import { bind } from "discourse/lib/decorators"; import { userPath } from "discourse/lib/url"; export default class PostListItem extends Component { @service site; @service siteSettings; @service currentUser; + @service appEvents; get moderatorActionClass() { return this.args.post.post_type === this.site.post_types.moderator_action @@ -70,6 +74,15 @@ export default class PostListItem extends Component { } } + @bind + decoratePostContent(element, helper) { + this.appEvents.trigger( + "decorate-non-stream-cooked-element", + element, + helper + ); + } +