visuddhinanda 2 роки тому
батько
коміт
cfe64efb68

+ 5 - 3
dashboard/src/components/discussion/DiscussionTopicChildren.tsx

@@ -43,6 +43,8 @@ const DiscussionTopicChildrenWidget = ({
   const [loading, setLoading] = useState(false);
   const [loading, setLoading] = useState(false);
   const [history, setHistory] = useState<ISentHistoryData[]>([]);
   const [history, setHistory] = useState<ISentHistoryData[]>([]);
   const [items, setItems] = useState<IItem[]>();
   const [items, setItems] = useState<IItem[]>();
+  const [currTopic, setCurrTopic] = useState(topic);
+
   console.log("topicId", topicId);
   console.log("topicId", topicId);
   useEffect(() => {
   useEffect(() => {
     if (loading === false) {
     if (loading === false) {
@@ -65,7 +67,7 @@ const DiscussionTopicChildrenWidget = ({
       };
       };
     });
     });
     const topicTime = new Date(
     const topicTime = new Date(
-      topic?.createdAt ? topic?.createdAt : ""
+      currTopic?.createdAt ? currTopic?.createdAt : ""
     ).getTime();
     ).getTime();
     let firstHis = history.findIndex(
     let firstHis = history.findIndex(
       (value) =>
       (value) =>
@@ -124,7 +126,7 @@ const DiscussionTopicChildrenWidget = ({
       });
       });
     }
     }
     setItems(newMixItems);
     setItems(newMixItems);
-  }, [data, history, topic?.createdAt]);
+  }, [data, history, currTopic?.createdAt]);
 
 
   useEffect(() => {
   useEffect(() => {
     if (resType === "sentence" && resId) {
     if (resType === "sentence" && resId) {
@@ -224,7 +226,7 @@ const DiscussionTopicChildrenWidget = ({
         resType={resType}
         resType={resType}
         contentType="markdown"
         contentType="markdown"
         parent={topicId}
         parent={topicId}
-        topic={topic}
+        topic={currTopic}
         onCreated={(e: IComment) => {
         onCreated={(e: IComment) => {
           const newData = JSON.parse(JSON.stringify(e));
           const newData = JSON.parse(JSON.stringify(e));
           setData([...data, newData]);
           setData([...data, newData]);