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

Remove onCommentCountUpdated and mutateCurrentPage

https://youtrack.weseek.co.jp/issue/GW-7961
- Remove onCommentCountUpdated props and its implementation
- Remove mutateCurrentPage from PageView
Mudana-Grune 2 лет назад
Родитель
Сommit
2a0af05f56

+ 1 - 6
apps/app/src/components/Comments.tsx

@@ -23,13 +23,12 @@ export type CommentsProps = {
   pagePath: string,
   pagePath: string,
   revision: IRevisionHasId,
   revision: IRevisionHasId,
   onLoaded?: () => void,
   onLoaded?: () => void,
-  onCommentCountUpdated?: () => void,
 }
 }
 
 
 export const Comments = (props: CommentsProps): JSX.Element => {
 export const Comments = (props: CommentsProps): JSX.Element => {
 
 
   const {
   const {
-    pageId, pagePath, revision, onLoaded, onCommentCountUpdated,
+    pageId, pagePath, revision, onLoaded,
   } = props;
   } = props;
 
 
   const { mutate } = useSWRxPageComment(pageId);
   const { mutate } = useSWRxPageComment(pageId);
@@ -72,9 +71,6 @@ export const Comments = (props: CommentsProps): JSX.Element => {
 
 
   const onCommentButtonClickHandler = () => {
   const onCommentButtonClickHandler = () => {
     mutate();
     mutate();
-    if (onCommentCountUpdated != null) {
-      onCommentCountUpdated();
-    }
   };
   };
 
 
   return (
   return (
@@ -89,7 +85,6 @@ export const Comments = (props: CommentsProps): JSX.Element => {
             isReadOnly={false}
             isReadOnly={false}
             titleAlign="left"
             titleAlign="left"
             hideIfEmpty={false}
             hideIfEmpty={false}
-            onCommentCountUpdated={onCommentCountUpdated}
           />
           />
         </div>
         </div>
         {!isDeleted && (
         {!isDeleted && (

+ 1 - 3
apps/app/src/components/Page/PageView.tsx

@@ -11,7 +11,7 @@ import { generateSSRViewOptions } from '~/services/renderer/renderer';
 import {
 import {
   useIsForbidden, useIsIdenticalPath, useIsNotCreatable,
   useIsForbidden, useIsIdenticalPath, useIsNotCreatable,
 } from '~/stores/context';
 } from '~/stores/context';
-import { useSWRxCurrentPage, useIsNotFound, useSWRMUTxCurrentPage } from '~/stores/page';
+import { useSWRxCurrentPage, useIsNotFound } from '~/stores/page';
 import { useViewOptions } from '~/stores/renderer';
 import { useViewOptions } from '~/stores/renderer';
 import { useIsMobile } from '~/stores/ui';
 import { useIsMobile } from '~/stores/ui';
 
 
@@ -67,7 +67,6 @@ export const PageView = (props: Props): JSX.Element => {
 
 
   const { data: pageBySWR } = useSWRxCurrentPage();
   const { data: pageBySWR } = useSWRxCurrentPage();
   const { data: viewOptions } = useViewOptions();
   const { data: viewOptions } = useViewOptions();
-  const { trigger: mutateCurrentPage } = useSWRMUTxCurrentPage();
 
 
   const page = pageBySWR ?? initialPage;
   const page = pageBySWR ?? initialPage;
   const isNotFound = isNotFoundMeta || page?.revision == null;
   const isNotFound = isNotFoundMeta || page?.revision == null;
@@ -117,7 +116,6 @@ export const PageView = (props: Props): JSX.Element => {
             pagePath={pagePath}
             pagePath={pagePath}
             revision={page.revision}
             revision={page.revision}
             onLoaded={() => setCommentsLoaded(true)}
             onLoaded={() => setCommentsLoaded(true)}
-            onCommentCountUpdated={mutateCurrentPage}
           />
           />
         </div>
         </div>
         {(isUsersHomePagePath && page.creator != null) && (
         {(isUsersHomePagePath && page.creator != null) && (

+ 3 - 10
apps/app/src/components/PageComment.tsx

@@ -40,14 +40,13 @@ export type PageCommentProps = {
   isReadOnly: boolean,
   isReadOnly: boolean,
   titleAlign?: 'center' | 'left' | 'right',
   titleAlign?: 'center' | 'left' | 'right',
   hideIfEmpty?: boolean,
   hideIfEmpty?: boolean,
-  onCommentCountUpdated?: () => void,
 }
 }
 
 
 export const PageComment: FC<PageCommentProps> = memo((props: PageCommentProps): JSX.Element => {
 export const PageComment: FC<PageCommentProps> = memo((props: PageCommentProps): JSX.Element => {
 
 
   const {
   const {
     rendererOptions: rendererOptionsByProps,
     rendererOptions: rendererOptionsByProps,
-    pageId, pagePath, revision, currentUser, isReadOnly, titleAlign, hideIfEmpty, onCommentCountUpdated,
+    pageId, pagePath, revision, currentUser, isReadOnly, titleAlign, hideIfEmpty,
   } = props;
   } = props;
 
 
   const { data: comments, mutate } = useSWRxPageComment(pageId);
   const { data: comments, mutate } = useSWRxPageComment(pageId);
@@ -85,10 +84,7 @@ export const PageComment: FC<PageCommentProps> = memo((props: PageCommentProps):
   const onDeleteCommentAfterOperation = useCallback(() => {
   const onDeleteCommentAfterOperation = useCallback(() => {
     onCancelDeleteComment();
     onCancelDeleteComment();
     mutate();
     mutate();
-    if (onCommentCountUpdated != null) {
-      onCommentCountUpdated();
-    }
-  }, [mutate, onCancelDeleteComment, onCommentCountUpdated]);
+  }, [mutate, onCancelDeleteComment]);
 
 
   const onDeleteComment = useCallback(async() => {
   const onDeleteComment = useCallback(async() => {
     if (commentToBeDeleted == null) return;
     if (commentToBeDeleted == null) return;
@@ -118,10 +114,7 @@ export const PageComment: FC<PageCommentProps> = memo((props: PageCommentProps):
   const onCommentButtonClickHandler = useCallback((commentId: string) => {
   const onCommentButtonClickHandler = useCallback((commentId: string) => {
     removeShowEditorId(commentId);
     removeShowEditorId(commentId);
     mutate();
     mutate();
-    if (onCommentCountUpdated != null) {
-      onCommentCountUpdated();
-    }
-  }, [removeShowEditorId, mutate, onCommentCountUpdated]);
+  }, [removeShowEditorId, mutate]);
 
 
   if (hideIfEmpty && comments?.length === 0) {
   if (hideIfEmpty && comments?.length === 0) {
     return <PageCommentRoot />;
     return <PageCommentRoot />;