visuddhinanda 2 лет назад
Родитель
Сommit
6da498376e
1 измененных файлов с 12 добавлено и 7 удалено
  1. 12 7
      dashboard/src/components/channel/ChannelMy.tsx

+ 12 - 7
dashboard/src/components/channel/ChannelMy.tsx

@@ -36,6 +36,17 @@ import CopyToModal from "./CopyToModal";
 import { ArticleType } from "../article/Article";
 import { ChannelInfoModal } from "./ChannelInfo";
 
+export const getSentIdInArticle = () => {
+  let sentList: string[] = [];
+  const sentElement = document.querySelectorAll(".pcd_sent");
+  for (let index = 0; index < sentElement.length; index++) {
+    const element = sentElement[index];
+    const id = element.id.split("_")[1];
+    sentList.push(id);
+  }
+  return sentList;
+};
+
 interface ChannelTreeNode {
   key: string;
   title: string | React.ReactNode;
@@ -158,13 +169,7 @@ const ChannelMy = ({
           });
       }
     } else {
-      const sentElement = document.querySelectorAll(".pcd_sent");
-      for (let index = 0; index < sentElement.length; index++) {
-        const element = sentElement[index];
-        const id = element.id.split("_")[1];
-        sentList.push(id);
-      }
-      setSentencesId(sentList);
+      setSentencesId(getSentIdInArticle());
       loadChannel(sentList);
     }
   };