shuashuai commented on code in PR #668:
URL: https://github.com/apache/incubator-answer/pull/668#discussion_r1423586163
##########
ui/src/pages/Questions/Detail/index.tsx:
##########
@@ -194,6 +194,7 @@ const Index = () => {
setQuestion({
...question,
answered: true,
+ first_answer_id: obj.id,
Review Comment:
This value is inaccurate. When the user has multiple answers, the value will
be the latest answer every time instead of the id of the first answer, which
can be obtained from the callback.
```
// Questions/Detail/index.tsx
const writeAnswerCallback = (obj: AnswerItem, firstAnswerId) => {
setAnswers({
count: answers.count + 1,
list: [...answers.list, obj],
});
if (question) {
setQuestion({
...question,
answered: true,
first_answer_id: firstAnswerId,
});
}
};
// Questions/Detail/components/WriteAnswer/index.tsx
interface Props {
....
callback?: (obj, id) => void;
}
// line 186
callback?.(res.info, res.question.first_answer_id);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]