From bf12e962dffa2620ceb6e12bba7458d301ee8298 Mon Sep 17 00:00:00 2001 From: awesomerobot Date: Wed, 16 Apr 2025 14:53:25 -0400 Subject: [PATCH] DEV: include excerpt-expanded class when gists are enabled --- .../initializers/ai-gist-topic-list-class.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 assets/javascripts/initializers/ai-gist-topic-list-class.js diff --git a/assets/javascripts/initializers/ai-gist-topic-list-class.js b/assets/javascripts/initializers/ai-gist-topic-list-class.js new file mode 100644 index 000000000..543a89f5c --- /dev/null +++ b/assets/javascripts/initializers/ai-gist-topic-list-class.js @@ -0,0 +1,19 @@ +import { apiInitializer } from "discourse/lib/api"; + +export default apiInitializer("1.15.0", (api) => { + const gistService = api.container.lookup("service:gists"); + + api.registerValueTransformer( + "topic-list-item-class", + ({ value, context }) => { + const shouldShow = + gistService.preference === "table-ai" && gistService.shouldShow; + + if (context.topic.get("ai_topic_gist") && shouldShow) { + value.push("excerpt-expanded"); + } + + return value; + } + ); +});