|
@@ -1,12 +1,8 @@
|
|
|
import { useEffect, useState } from "react";
|
|
import { useEffect, useState } from "react";
|
|
|
-import { ArrowLeftOutlined } from "@ant-design/icons";
|
|
|
|
|
|
|
|
|
|
-import DiscussionTopic from "./DiscussionTopic";
|
|
|
|
|
-import DiscussionListCard from "./DiscussionListCard";
|
|
|
|
|
import { IComment } from "./DiscussionItem";
|
|
import { IComment } from "./DiscussionItem";
|
|
|
import { useAppSelector } from "../../hooks";
|
|
import { useAppSelector } from "../../hooks";
|
|
|
import {
|
|
import {
|
|
|
- countChange,
|
|
|
|
|
IShowDiscussion,
|
|
IShowDiscussion,
|
|
|
message,
|
|
message,
|
|
|
show,
|
|
show,
|
|
@@ -14,6 +10,7 @@ import {
|
|
|
} from "../../reducers/discussion";
|
|
} from "../../reducers/discussion";
|
|
|
import { Button } from "antd";
|
|
import { Button } from "antd";
|
|
|
import store from "../../store";
|
|
import store from "../../store";
|
|
|
|
|
+import Discussion from "./Discussion";
|
|
|
|
|
|
|
|
export interface IAnswerCount {
|
|
export interface IAnswerCount {
|
|
|
id: string;
|
|
id: string;
|
|
@@ -25,10 +22,7 @@ interface IWidget {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const DiscussionBoxWidget = ({ onTopicChange }: IWidget) => {
|
|
const DiscussionBoxWidget = ({ onTopicChange }: IWidget) => {
|
|
|
- const [childrenDrawer, setChildrenDrawer] = useState(false);
|
|
|
|
|
const [topicId, setTopicId] = useState<string>();
|
|
const [topicId, setTopicId] = useState<string>();
|
|
|
- const [topic, setTopic] = useState<IComment>();
|
|
|
|
|
- const [answerCount, setAnswerCount] = useState<IAnswerCount>();
|
|
|
|
|
const [currTopic, setCurrTopic] = useState<IComment>();
|
|
const [currTopic, setCurrTopic] = useState<IComment>();
|
|
|
|
|
|
|
|
const discussionMessage = useAppSelector(message);
|
|
const discussionMessage = useAppSelector(message);
|
|
@@ -36,25 +30,12 @@ const DiscussionBoxWidget = ({ onTopicChange }: IWidget) => {
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
if (discussionMessage) {
|
|
if (discussionMessage) {
|
|
|
if (discussionMessage.topic) {
|
|
if (discussionMessage.topic) {
|
|
|
- setChildrenDrawer(true);
|
|
|
|
|
setTopicId(discussionMessage.topic);
|
|
setTopicId(discussionMessage.topic);
|
|
|
} else {
|
|
} else {
|
|
|
- setChildrenDrawer(false);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}, [discussionMessage]);
|
|
}, [discussionMessage]);
|
|
|
|
|
|
|
|
- const showChildrenDrawer = (comment: IComment) => {
|
|
|
|
|
- setChildrenDrawer(true);
|
|
|
|
|
- if (comment.id) {
|
|
|
|
|
- setTopicId(comment.id);
|
|
|
|
|
- setTopic(undefined);
|
|
|
|
|
- } else {
|
|
|
|
|
- setTopicId(undefined);
|
|
|
|
|
- setTopic(comment);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<Button
|
|
<Button
|
|
@@ -73,51 +54,15 @@ const DiscussionBoxWidget = ({ onTopicChange }: IWidget) => {
|
|
|
>
|
|
>
|
|
|
显示译文
|
|
显示译文
|
|
|
</Button>
|
|
</Button>
|
|
|
- {childrenDrawer ? (
|
|
|
|
|
- <div>
|
|
|
|
|
- <Button
|
|
|
|
|
- shape="circle"
|
|
|
|
|
- icon={<ArrowLeftOutlined />}
|
|
|
|
|
- onClick={() => setChildrenDrawer(false)}
|
|
|
|
|
- />
|
|
|
|
|
- <DiscussionTopic
|
|
|
|
|
- resType={discussionMessage?.resType}
|
|
|
|
|
- topicId={topicId}
|
|
|
|
|
- topic={topic}
|
|
|
|
|
- focus={discussionMessage?.comment}
|
|
|
|
|
- onItemCountChange={(count: number, parent: string) => {
|
|
|
|
|
- setAnswerCount({ id: parent, count: count });
|
|
|
|
|
- }}
|
|
|
|
|
- onTopicReady={(value: IComment) => {
|
|
|
|
|
- setCurrTopic(value);
|
|
|
|
|
- }}
|
|
|
|
|
- onTopicDelete={() => {
|
|
|
|
|
- setChildrenDrawer(false);
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
- ) : (
|
|
|
|
|
- <DiscussionListCard
|
|
|
|
|
- resId={discussionMessage?.resId}
|
|
|
|
|
- resType={discussionMessage?.resType}
|
|
|
|
|
- onSelect={(
|
|
|
|
|
- e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
|
|
|
|
|
- comment: IComment
|
|
|
|
|
- ) => showChildrenDrawer(comment)}
|
|
|
|
|
- onReply={(comment: IComment) => showChildrenDrawer(comment)}
|
|
|
|
|
- onReady={() => {}}
|
|
|
|
|
- changedAnswerCount={answerCount}
|
|
|
|
|
- onItemCountChange={(count: number) => {
|
|
|
|
|
- store.dispatch(
|
|
|
|
|
- countChange({
|
|
|
|
|
- count: count,
|
|
|
|
|
- resId: discussionMessage?.resId,
|
|
|
|
|
- resType: discussionMessage?.resType,
|
|
|
|
|
- })
|
|
|
|
|
- );
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ <Discussion
|
|
|
|
|
+ resId={discussionMessage?.resId}
|
|
|
|
|
+ resType={discussionMessage?.resType}
|
|
|
|
|
+ focus={discussionMessage?.comment}
|
|
|
|
|
+ showTopicId={topicId}
|
|
|
|
|
+ onTopicReady={(value: IComment) => {
|
|
|
|
|
+ setCurrTopic(value);
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|