mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-02-07 04:08:11 +00:00
DEV: Use topic-list-item-class
transformer (#321)
…to replace a deprecated topic-list-item customization
This commit is contained in:
parent
41a8789ec3
commit
024d9dd70f
@ -1,18 +1,36 @@
|
||||
import TopicListItem from "discourse/components/topic-list-item";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { withSilencedDeprecations } from "discourse-common/lib/deprecated";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
|
||||
export default {
|
||||
name: "add-topic-list-class",
|
||||
|
||||
initialize() {
|
||||
TopicListItem.reopen({
|
||||
@discourseComputed()
|
||||
unboundClassNames() {
|
||||
let classList = this._super(...arguments);
|
||||
if (this.topic.has_accepted_answer) {
|
||||
classList += " status-solved";
|
||||
withPluginApi("1.39.0", (api) => {
|
||||
// TODO: cvx - remove after the glimmer topic list transition
|
||||
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
|
||||
TopicListItem.reopen({
|
||||
@discourseComputed()
|
||||
unboundClassNames() {
|
||||
let classList = this._super(...arguments);
|
||||
if (this.topic.has_accepted_answer) {
|
||||
classList += " status-solved";
|
||||
}
|
||||
return classList;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
api.registerValueTransformer(
|
||||
"topic-list-item-class",
|
||||
({ value, context }) => {
|
||||
if (context.topic.get("has_accepted_answer")) {
|
||||
value.push("status-solved");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return classList;
|
||||
},
|
||||
);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user