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 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";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "add-topic-list-class",
|
name: "add-topic-list-class",
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
TopicListItem.reopen({
|
withPluginApi("1.39.0", (api) => {
|
||||||
@discourseComputed()
|
// TODO: cvx - remove after the glimmer topic list transition
|
||||||
unboundClassNames() {
|
withSilencedDeprecations("discourse.hbr-topic-list-overrides", () => {
|
||||||
let classList = this._super(...arguments);
|
TopicListItem.reopen({
|
||||||
if (this.topic.has_accepted_answer) {
|
@discourseComputed()
|
||||||
classList += " status-solved";
|
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