Просмотр исходного кода

Merge pull request #1451 from visuddhinanda/agile

添加新句子,count 改变 #1447
visuddhinanda 2 лет назад
Родитель
Сommit
7a3af52139

+ 5 - 0
dashboard/src/components/template/SentEdit/SentCanRead.tsx

@@ -22,6 +22,7 @@ interface IWidget {
   channelsId?: string[];
   reload?: boolean;
   onReload?: Function;
+  onCreate?: Function;
 }
 const SentCanReadWidget = ({
   book,
@@ -32,6 +33,7 @@ const SentCanReadWidget = ({
   channelsId,
   reload = false,
   onReload,
+  onCreate,
 }: IWidget) => {
   const [sentData, setSentData] = useState<ISentence[]>([]);
   const [channels, setChannels] = useState<string[]>();
@@ -140,6 +142,9 @@ const SentCanReadWidget = ({
               return [newSent.channel.id];
             }
           });
+          if (typeof onCreate !== "undefined") {
+            onCreate();
+          }
         }}
       />
 

+ 18 - 9
dashboard/src/components/template/SentEdit/SentTab.tsx

@@ -50,9 +50,9 @@ const SentTabWidget = ({
   wordEnd,
   channelsId,
   path,
-  tranNum,
-  nissayaNum,
-  commNum,
+  tranNum = 0,
+  nissayaNum = 0,
+  commNum = 0,
   originNum,
   simNum = 0,
   wbwData,
@@ -68,6 +68,10 @@ const SentTabWidget = ({
   const [isCompact, setIsCompact] = useState(compact);
   const [hover, setHover] = useState(false);
   const [currKey, setCurrKey] = useState("close");
+  const [currTranNum, setCurrTranNum] = useState(tranNum);
+  const [currNissayaNum, setCurrNissayaNum] = useState(nissayaNum);
+  const [currCommNum, setCurrCommNum] = useState(commNum);
+
   useEffect(() => setIsCompact(compact), [compact]);
   const mPath = path
     ? [
@@ -179,8 +183,8 @@ const SentTabWidget = ({
               type="translation"
               sentId={id}
               count={
-                tranNum
-                  ? tranNum -
+                currTranNum
+                  ? currTranNum -
                     (loadedRes?.translation ? loadedRes.translation : 0)
                   : undefined
               }
@@ -198,6 +202,7 @@ const SentTabWidget = ({
               wordEnd={parseInt(sId[3])}
               type="translation"
               channelsId={channelsId}
+              onCreate={() => setCurrTranNum((origin) => origin + 1)}
             />
           ),
         },
@@ -209,8 +214,9 @@ const SentTabWidget = ({
               type="nissaya"
               sentId={id}
               count={
-                nissayaNum
-                  ? nissayaNum - (loadedRes?.nissaya ? loadedRes.nissaya : 0)
+                currNissayaNum
+                  ? currNissayaNum -
+                    (loadedRes?.nissaya ? loadedRes.nissaya : 0)
                   : undefined
               }
               title={intl.formatMessage({
@@ -227,6 +233,7 @@ const SentTabWidget = ({
               wordEnd={parseInt(sId[3])}
               type="nissaya"
               channelsId={channelsId}
+              onCreate={() => setCurrNissayaNum((origin) => origin + 1)}
             />
           ),
         },
@@ -238,8 +245,9 @@ const SentTabWidget = ({
               type="commentary"
               sentId={id}
               count={
-                commNum
-                  ? commNum - (loadedRes?.commentary ? loadedRes.commentary : 0)
+                currCommNum
+                  ? currCommNum -
+                    (loadedRes?.commentary ? loadedRes.commentary : 0)
                   : undefined
               }
               title={intl.formatMessage({
@@ -256,6 +264,7 @@ const SentTabWidget = ({
               wordEnd={parseInt(sId[3])}
               type="commentary"
               channelsId={channelsId}
+              onCreate={() => setCurrCommNum((origin) => origin + 1)}
             />
           ),
         },