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

View File

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