Skip to content

Commit 024d9dd

Browse files
authored
DEV: Use topic-list-item-class transformer (#321)
…to replace a deprecated topic-list-item customization
1 parent 41a8789 commit 024d9dd

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed
Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
import TopicListItem from "discourse/components/topic-list-item";
2+
import { withPluginApi } from "discourse/lib/plugin-api";
3+
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
24
import discourseComputed from "discourse-common/utils/decorators";
35

46
export default {
57
name: "add-topic-list-class",
8+
69
initialize() {
7-
TopicListItem.reopen({
8-
@discourseComputed()
9-
unboundClassNames() {
10-
let classList = this._super(...arguments);
11-
if (this.topic.has_accepted_answer) {
12-
classList += " status-solved";
10+
withPluginApi("1.39.0", (api) => {
11+
// TODO: cvx - remove after the glimmer topic list transition
12+
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
13+
TopicListItem.reopen({
14+
@discourseComputed()
15+
unboundClassNames() {
16+
let classList = this._super(...arguments);
17+
if (this.topic.has_accepted_answer) {
18+
classList += " status-solved";
19+
}
20+
return classList;
21+
},
22+
});
23+
});
24+
25+
api.registerValueTransformer(
26+
"topic-list-item-class",
27+
({ value, context }) => {
28+
if (context.topic.get("has_accepted_answer")) {
29+
value.push("status-solved");
30+
}
31+
return value;
1332
}
14-
return classList;
15-
},
33+
);
1634
});
1735
},
1836
};

0 commit comments

Comments
 (0)