FIX: Use both possible *_answer attributes (#329)

…and simplify other conditions (`can_have_answer` is true only if `solved_enabled` and `empty_box_on_unsolved` are also true)
This commit is contained in:
Jarek Radosz 2025-01-23 03:53:48 +01:00 committed by GitHub
parent e6cda87505
commit c929f49f3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 16 deletions

View File

@ -1,6 +1,6 @@
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { service } from "@ember/service"; import { service } from "@ember/service";
import { and } from "truth-helpers"; import { or } from "truth-helpers";
import icon from "discourse/helpers/d-icon"; import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n"; import { i18n } from "discourse-i18n";
@ -8,18 +8,16 @@ export default class SolvedStatus extends Component {
@service siteSettings; @service siteSettings;
<template> <template>
{{~#if @outletArgs.topic.has_accepted_answer~}} {{~#if
(or
@outletArgs.topic.has_accepted_answer @outletArgs.topic.accepted_answer
)
~}}
<span <span
title={{i18n "topic_statuses.solved.help"}} title={{i18n "topic_statuses.solved.help"}}
class="topic-status" class="topic-status"
>{{icon "far-square-check"}}</span> >{{icon "far-square-check"}}</span>
{{~else if {{~else if @outletArgs.topic.can_have_answer~}}
(and
@outletArgs.topic.can_have_answer
this.siteSettings.solved_enabled
this.siteSettings.empty_box_on_unsolved
)
~}}
<span <span
title={{i18n "solved.has_no_accepted_answer"}} title={{i18n "solved.has_no_accepted_answer"}}
class="topic-status" class="topic-status"

View File

@ -216,11 +216,16 @@ export default {
"raw-view:topic-status", "raw-view:topic-status",
(Superclass) => (Superclass) =>
class extends Superclass { class extends Superclass {
@discourseComputed("topic.{has_accepted_answer,can_have_answer}") @discourseComputed(
"topic.{has_accepted_answer,accepted_answer,can_have_answer}"
)
statuses() { statuses() {
const results = super.statuses; const results = super.statuses;
if (this.topic.has_accepted_answer) { if (
this.topic.has_accepted_answer ||
this.topic.accepted_answer
) {
results.push({ results.push({
openTag: "span", openTag: "span",
closeTag: "span", closeTag: "span",
@ -228,11 +233,7 @@ export default {
icon: "far-square-check", icon: "far-square-check",
key: "solved", key: "solved",
}); });
} else if ( } else if (this.topic.can_have_answer) {
this.topic.can_have_answer &&
this.siteSettings.solved_enabled &&
this.siteSettings.empty_box_on_unsolved
) {
results.push({ results.push({
openTag: "span", openTag: "span",
closeTag: "span", closeTag: "span",