Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,52 +86,46 @@ function initializeWithApi(api) {
}

api.addPostMenuButton("solved", (attrs) => {
const canAccept = attrs.can_accept_answer;
const canUnaccept = attrs.can_unaccept_answer;
const accepted = attrs.accepted_answer;
const isOp = currentUser && currentUser.id === attrs.topicCreatedById;
const position =
!accepted && canAccept && !isOp ? "second-last-hidden" : "first";

if (canAccept) {
const isOp = currentUser?.id === attrs.topicCreatedById;

if (attrs.can_accept_answer) {
return {
action: "acceptAnswer",
icon: "far-check-square",
className: "unaccepted",
title: "solved.accept_answer",
label: "solved.solution",
position,
};
} else if (canUnaccept && accepted) {
const title = canUnaccept
? "solved.unaccept_answer"
: "solved.accepted_answer";
return {
action: "unacceptAnswer",
icon: "check-square",
title,
className: "accepted fade-out",
position,
label: "solved.solution",
};
} else if (!canAccept && accepted) {
return {
className: "hidden",
disabled: "true",
position,
beforeButton(h) {
return h(
"span.accepted-text",
{
title: I18n.t("solved.accepted_description"),
},
[
h("span", iconNode("check")),
h("span.accepted-label", I18n.t("solved.solution")),
]
);
},
label: isOp ? "solved.solution" : null,
position: isOp ? "first" : "second",
};
} else if (attrs.accepted_answer) {
if (attrs.can_unaccept_answer) {
return {
action: "unacceptAnswer",
icon: "check-square",
title: "solved.unaccept_answer",
className: "accepted fade-out",
position: isOp ? "first" : "second",
label: isOp ? "solved.solution" : null,
};
} else {
return {
className: "hidden",
disabled: "true",
position: "first",
beforeButton(h) {
return h(
"span.accepted-text",
{
title: I18n.t("solved.accepted_description"),
},
[
h("span", iconNode("check")),
h("span.accepted-label", I18n.t("solved.solution")),
]
);
},
};
}
}
});

Expand Down