Shun Miyazawa 4 years ago
parent
commit
5ed1c0161e

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

@@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
 
 
 import UserPictureList from './User/UserPictureList';
 import UserPictureList from './User/UserPictureList';
 import { toastError } from '~/client/util/apiNotification';
 import { toastError } from '~/client/util/apiNotification';
-import { useIsGuestUser } from '~/stores/context';
+import { usePageId, useIsGuestUser } from '~/stores/context';
 import { apiv3Put } from '~/client/util/apiv3-client';
 import { apiv3Put } from '~/client/util/apiv3-client';
 
 
 interface Props {
 interface Props {
@@ -15,10 +15,10 @@ interface Props {
 
 
 const LikeButtons: FC<Props> = (props: Props) => {
 const LikeButtons: FC<Props> = (props: Props) => {
   const { t } = useTranslation();
   const { t } = useTranslation();
-  const { pageId } = props;
 
 
   const [isPopoverOpen, setIsPopoverOpen] = useState(false);
   const [isPopoverOpen, setIsPopoverOpen] = useState(false);
 
 
+  const { data: pageId } = usePageId();
   const { data: isGuestUser } = useIsGuestUser();
   const { data: isGuestUser } = useIsGuestUser();
 
 
   // TODO: Get the following values in SWR
   // TODO: Get the following values in SWR
@@ -37,8 +37,7 @@ const LikeButtons: FC<Props> = (props: Props) => {
     }
     }
 
 
     try {
     try {
-      // eslint-disable-next-line @typescript-eslint/no-unused-vars
-      const res = await apiv3Put('/page/likes', { pageId, bool: isLiked });
+      await apiv3Put('/page/likes', { pageId, bool: isLiked });
     }
     }
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);

+ 1 - 1
packages/app/src/components/Navbar/SubNavButtons.jsx

@@ -27,7 +27,7 @@ const SubnavButtons = React.memo((props) => {
         </span>
         </span>
         {pageContainer.isAbleToShowLikeButtons && (
         {pageContainer.isAbleToShowLikeButtons && (
           <span>
           <span>
-            <LikeButtons pageId={pageContainer.state.pageId} />
+            <LikeButtons />
           </span>
           </span>
         )}
         )}
         <span>
         <span>