Sfoglia il codice sorgente

81110 remove unnecessary code

Yohei-Shiina 4 anni fa
parent
commit
3d5b2bb684

+ 1 - 5
packages/app/src/components/Navbar/SubNavButtons.tsx

@@ -25,7 +25,7 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
   const { editorMode } = navigationContainer.state;
   const isViewMode = editorMode === 'view';
   const { data: pageInfo, error: pageInfoError, mutate: mutatePageInfo } = useSWRPageInfo(pageId);
-  const { data: likers, mutate: mutateLikerList } = useSWRxLikerList(pageInfo?.likerIds);
+  const { data: likers } = useSWRxLikerList(pageInfo?.likerIds);
 
   const likeClickhandler = useCallback(async() => {
     const { isGuestUser } = appContainer;
@@ -44,10 +44,6 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
     }
   }, [pageInfo]);
 
-  useEffect(() => {
-    mutateLikerList();
-  }, [pageInfo]);
-
   if (pageInfoError != null || pageInfo == null) {
     return <></>;
   }

+ 3 - 5
packages/app/src/stores/user.tsx

@@ -2,11 +2,9 @@ import useSWR, { SWRResponse } from 'swr';
 import { IUser } from '../interfaces/user';
 import { apiGet } from '../client/util/apiv1-client';
 
-const userFetcher = (endpoint:string, userIds:string) => {
-  return apiGet(endpoint, { user_ids: userIds }).then((response:any) => response.users);
-};
-
 export const useSWRxLikerList = (likerIds: string[] = []): SWRResponse<IUser[], Error> => {
   const shouldFetch = likerIds.length > 0;
-  return useSWR(shouldFetch ? ['/users.list', [...likerIds].join(',')] : null, userFetcher);
+  return useSWR(shouldFetch ? ['/users.list', [...likerIds].join(',')] : null, (endpoint:string, userIds:string) => {
+    return apiGet(endpoint, { user_ids: userIds }).then((response:any) => response.users);
+  });
 };