mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-07-04 04:42:12 +00:00
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:
parent
855745b4f8
commit
f03f64a33c
@ -22,7 +22,7 @@ function unacceptPost(post) {
|
|||||||
accepted_answer: false,
|
accepted_answer: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
topic.set("accepted_answer", undefined);
|
topic.accepted_answer = undefined;
|
||||||
|
|
||||||
ajax("/solution/unaccept", {
|
ajax("/solution/unaccept", {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -8,7 +8,7 @@ export default {
|
|||||||
api.registerValueTransformer(
|
api.registerValueTransformer(
|
||||||
"topic-list-item-class",
|
"topic-list-item-class",
|
||||||
({ value, context }) => {
|
({ value, context }) => {
|
||||||
if (context.topic.get("has_accepted_answer")) {
|
if (context.topic.has_accepted_answer) {
|
||||||
value.push("status-solved");
|
value.push("status-solved");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
|
import { tracked } from "@glimmer/tracking";
|
||||||
import { withSilencedDeprecations } from "discourse/lib/deprecated";
|
import { withSilencedDeprecations } from "discourse/lib/deprecated";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
import RenderGlimmer from "discourse/widgets/render-glimmer";
|
||||||
@ -24,6 +25,15 @@ function customizePost(api) {
|
|||||||
"topic_accepted_answer"
|
"topic_accepted_answer"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
api.modifyClass(
|
||||||
|
"model:topic",
|
||||||
|
(Superclass) =>
|
||||||
|
class extends Superclass {
|
||||||
|
@tracked accepted_answer;
|
||||||
|
@tracked has_accepted_answer;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
api.renderAfterWrapperOutlet(
|
api.renderAfterWrapperOutlet(
|
||||||
"post-content-cooked-html",
|
"post-content-cooked-html",
|
||||||
class extends Component {
|
class extends Component {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user