FEATURE: Show notice if user can accept an answer (#175)
Implements a a notice that will show for old topics with no accepted answers.
This commit is contained in:
parent
8635fed3d6
commit
4bb06f0e16
|
@ -0,0 +1,6 @@
|
||||||
|
{{#if show}}
|
||||||
|
{{#topic-navigation-popup}}
|
||||||
|
<h3>{{i18n "solved.no_answer.title"}}</h3>
|
||||||
|
<p>{{i18n "solved.no_answer.description"}}</p>
|
||||||
|
{{/topic-navigation-popup}}
|
||||||
|
{{/if}}
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { later } from "@ember/runloop";
|
||||||
|
|
||||||
|
// 7 days in milliseconds
|
||||||
|
const MAX_DURATION_WITH_NO_ANSWER = 7 * 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setupComponent(args, component) {
|
||||||
|
component.set("show", false);
|
||||||
|
|
||||||
|
later(() => {
|
||||||
|
if (
|
||||||
|
!component.element ||
|
||||||
|
component.isDestroying ||
|
||||||
|
component.isDestroyed
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const topic = args.topic;
|
||||||
|
const currentUser = component.currentUser;
|
||||||
|
|
||||||
|
// show notice if:
|
||||||
|
// - user can accept answer
|
||||||
|
// - it does not have an accepted answer
|
||||||
|
// - topic is old
|
||||||
|
// - topic has at least one reply from another user that can be accepted
|
||||||
|
if (
|
||||||
|
!topic.accepted_answer &&
|
||||||
|
currentUser &&
|
||||||
|
topic.user_id === currentUser.id &&
|
||||||
|
moment() - moment(topic.created_at) > MAX_DURATION_WITH_NO_ANSWER &&
|
||||||
|
topic.postStream.posts.some(
|
||||||
|
(post) => post.user_id !== currentUser.id && post.can_accept_answer
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
component.set("show", true);
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
},
|
||||||
|
};
|
|
@ -27,6 +27,10 @@ en:
|
||||||
no_solved_topics_title: "You haven’t solved any topics yet"
|
no_solved_topics_title: "You haven’t solved any topics yet"
|
||||||
no_solved_topics_body: "When you provide a helpful reply to a topic, your reply might be selected as the solution by the topic owner or staff."
|
no_solved_topics_body: "When you provide a helpful reply to a topic, your reply might be selected as the solution by the topic owner or staff."
|
||||||
|
|
||||||
|
no_answer:
|
||||||
|
title: Has your question been answered?
|
||||||
|
description: "Highlight the answer and help others by using the solution button below the correct reply."
|
||||||
|
|
||||||
topic_statuses:
|
topic_statuses:
|
||||||
solved:
|
solved:
|
||||||
help: "This topic has a solution"
|
help: "This topic has a solution"
|
||||||
|
|
Loading…
Reference in New Issue