DEV: Refactor topic model to use tracked properties for accepted answer logic

Refactored the `topic` model to replace legacy Ember property access (`get/set`) with modern tracked properties. Updated related logic in `add-topic-list-class` and `solved-unaccept-answer-button` to align with these changes.
This commit is contained in:
Sérgio Saquetim 2025-06-20 19:07:35 -03:00
parent 855745b4f8
commit f03f64a33c
No known key found for this signature in database
GPG Key ID: B4E3D7F11E793062
3 changed files with 12 additions and 2 deletions

View File

@ -22,7 +22,7 @@ function unacceptPost(post) {
accepted_answer: false,
});
topic.set("accepted_answer", undefined);
topic.accepted_answer = undefined;
ajax("/solution/unaccept", {
type: "POST",

View File

@ -8,7 +8,7 @@ export default {
api.registerValueTransformer(
"topic-list-item-class",
({ value, context }) => {
if (context.topic.get("has_accepted_answer")) {
if (context.topic.has_accepted_answer) {
value.push("status-solved");
}
return value;

View File

@ -1,4 +1,5 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { withSilencedDeprecations } from "discourse/lib/deprecated";
import { withPluginApi } from "discourse/lib/plugin-api";
import RenderGlimmer from "discourse/widgets/render-glimmer";
@ -24,6 +25,15 @@ function customizePost(api) {
"topic_accepted_answer"
);
api.modifyClass(
"model:topic",
(Superclass) =>
class extends Superclass {
@tracked accepted_answer;
@tracked has_accepted_answer;
}
);
api.renderAfterWrapperOutlet(
"post-content-cooked-html",
class extends Component {