From 3440395623d5cb285b5205149ef428d5c8e192d7 Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 16 Apr 2025 15:26:04 -0400 Subject: [PATCH] DEV: include excerpt-expanded class when gists are enabled (#1267) --- .../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 00000000..543a89f5 --- /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; + } + ); +});