Explorar el Código

81110 remove unnecessary codes

Yohei-Shiina hace 4 años
padre
commit
fb070a3e28

+ 4 - 8
packages/app/src/components/LikeButtons.tsx

@@ -6,15 +6,12 @@ import UserPictureList from './User/UserPictureList';
 import { withUnstatedContainers } from './UnstatedUtils';
 import { withUnstatedContainers } from './UnstatedUtils';
 
 
 import AppContainer from '~/client/services/AppContainer';
 import AppContainer from '~/client/services/AppContainer';
-import { useSWRPageInfo } from '../stores/page';
 import { IUser } from '../interfaces/user';
 import { IUser } from '../interfaces/user';
 
 
 type LikeButtonsProps = {
 type LikeButtonsProps = {
   appContainer: AppContainer,
   appContainer: AppContainer,
-  likerIds: string[],
   sumOfLikers: number,
   sumOfLikers: number,
   isLiked: boolean,
   isLiked: boolean,
-  pageId: string,
   likers: IUser[],
   likers: IUser[],
   onLikeClicked?: ()=>void,
   onLikeClicked?: ()=>void,
   t: (s:string)=>string,
   t: (s:string)=>string,
@@ -22,7 +19,6 @@ type LikeButtonsProps = {
 
 
 const LikeButtons: FC<LikeButtonsProps> = (props: LikeButtonsProps) => {
 const LikeButtons: FC<LikeButtonsProps> = (props: LikeButtonsProps) => {
   const [isPopoverOpen, setIsPopoverOpen] = useState(false);
   const [isPopoverOpen, setIsPopoverOpen] = useState(false);
-  const { data: pageInfo } = useSWRPageInfo(props.pageId);
 
 
   const togglePopover = () => {
   const togglePopover = () => {
     setIsPopoverOpen(!isPopoverOpen);
     setIsPopoverOpen(!isPopoverOpen);
@@ -37,7 +33,7 @@ const LikeButtons: FC<LikeButtonsProps> = (props: LikeButtonsProps) => {
   };
   };
 
 
   const {
   const {
-    appContainer, t,
+    appContainer, isLiked, sumOfLikers, t,
   } = props;
   } = props;
   const { isGuestUser } = appContainer;
   const { isGuestUser } = appContainer;
 
 
@@ -48,7 +44,7 @@ const LikeButtons: FC<LikeButtonsProps> = (props: LikeButtonsProps) => {
         id="like-button"
         id="like-button"
         onClick={handleClick}
         onClick={handleClick}
         className={`btn btn-like border-0
         className={`btn btn-like border-0
-            ${pageInfo?.isLiked ? 'active' : ''} ${isGuestUser ? 'disabled' : ''}`}
+            ${isLiked ? 'active' : ''} ${isGuestUser ? 'disabled' : ''}`}
       >
       >
         <i className="icon-like"></i>
         <i className="icon-like"></i>
       </button>
       </button>
@@ -58,8 +54,8 @@ const LikeButtons: FC<LikeButtonsProps> = (props: LikeButtonsProps) => {
         </UncontrolledTooltip>
         </UncontrolledTooltip>
       )}
       )}
 
 
-      <button type="button" id="po-total-likes" className={`btn btn-like border-0 total-likes ${pageInfo?.isLiked ? 'active' : ''}`}>
-        {pageInfo?.sumOfLikers}
+      <button type="button" id="po-total-likes" className={`btn btn-like border-0 total-likes ${isLiked ? 'active' : ''}`}>
+        {sumOfLikers}
       </button>
       </button>
       <Popover placement="bottom" isOpen={isPopoverOpen} target="po-total-likes" toggle={togglePopover} trigger="legacy">
       <Popover placement="bottom" isOpen={isPopoverOpen} target="po-total-likes" toggle={togglePopover} trigger="legacy">
         <PopoverBody className="seen-user-popover">
         <PopoverBody className="seen-user-popover">

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

@@ -57,7 +57,7 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
   if (pageInfoError != null || pageInfo == null) {
   if (pageInfoError != null || pageInfo == null) {
     return <></>;
     return <></>;
   }
   }
-  const { sumOfLikers, likerIds, isLiked } = pageInfo;
+  const { sumOfLikers, isLiked } = pageInfo;
 
 
   return (
   return (
     <>
     <>
@@ -65,7 +65,6 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
         <PageReactionButtons
         <PageReactionButtons
           pageId={pageId}
           pageId={pageId}
           sumOfLikers={sumOfLikers}
           sumOfLikers={sumOfLikers}
-          likerIds={likerIds}
           isLiked={isLiked}
           isLiked={isLiked}
           likers={likers}
           likers={likers}
           onLikeClicked={likeClickhandler}
           onLikeClicked={likeClickhandler}

+ 1 - 4
packages/app/src/components/PageReactionButtons.tsx

@@ -5,7 +5,6 @@ import { IUser } from '../interfaces/user';
 type Props = {
 type Props = {
   pageId: string,
   pageId: string,
   sumOfLikers: number,
   sumOfLikers: number,
-  likerIds: string[],
   isLiked: boolean,
   isLiked: boolean,
   likers: IUser[],
   likers: IUser[],
   onLikeClicked?: ()=>void,
   onLikeClicked?: ()=>void,
@@ -14,7 +13,7 @@ type Props = {
 
 
 const PageReactionButtons : FC<Props> = (props: Props) => {
 const PageReactionButtons : FC<Props> = (props: Props) => {
   const {
   const {
-    pageId, sumOfLikers, likerIds, isLiked, likers, onLikeClicked,
+    sumOfLikers, isLiked, likers, onLikeClicked,
   } = props;
   } = props;
 
 
 
 
@@ -23,8 +22,6 @@ const PageReactionButtons : FC<Props> = (props: Props) => {
       <span>
       <span>
         <LikeButtons
         <LikeButtons
           onLikeClicked={onLikeClicked}
           onLikeClicked={onLikeClicked}
-          pageId={pageId}
-          likerIds={likerIds}
           sumOfLikers={sumOfLikers}
           sumOfLikers={sumOfLikers}
           isLiked={isLiked}
           isLiked={isLiked}
           likers={likers}
           likers={likers}