|
@@ -1,5 +1,5 @@
|
|
|
import React, {
|
|
import React, {
|
|
|
- FC, useCallback,
|
|
|
|
|
|
|
+ FC, useCallback, useState, useEffect,
|
|
|
} from 'react';
|
|
} from 'react';
|
|
|
import AppContainer from '../../client/services/AppContainer';
|
|
import AppContainer from '../../client/services/AppContainer';
|
|
|
import NavigationContainer from '../../client/services/NavigationContainer';
|
|
import NavigationContainer from '../../client/services/NavigationContainer';
|
|
@@ -11,7 +11,7 @@ import { useSWRPageInfo } from '../../stores/page';
|
|
|
import { useSWRBookmarkInfo } from '../../stores/bookmark';
|
|
import { useSWRBookmarkInfo } from '../../stores/bookmark';
|
|
|
import { toastError } from '../../client/util/apiNotification';
|
|
import { toastError } from '../../client/util/apiNotification';
|
|
|
import { apiv3Put } from '../../client/util/apiv3-client';
|
|
import { apiv3Put } from '../../client/util/apiv3-client';
|
|
|
-
|
|
|
|
|
|
|
+import { useSWRxLikerList } from '../../stores/user';
|
|
|
|
|
|
|
|
type SubNavButtonsProps= {
|
|
type SubNavButtonsProps= {
|
|
|
appContainer: AppContainer,
|
|
appContainer: AppContainer,
|
|
@@ -33,9 +33,11 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
|
|
|
const { isGuestUser } = appContainer;
|
|
const { isGuestUser } = appContainer;
|
|
|
|
|
|
|
|
const { data: pageInfo, error: pageInfoError, mutate: mutatePageInfo } = useSWRPageInfo(pageId);
|
|
const { data: pageInfo, error: pageInfoError, mutate: mutatePageInfo } = useSWRPageInfo(pageId);
|
|
|
|
|
+ const { data: likers } = useSWRxLikerList(pageInfo?.likerIds);
|
|
|
const { data: bookmarkInfo, error: bookmarkInfoError, mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageId);
|
|
const { data: bookmarkInfo, error: bookmarkInfoError, mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageId);
|
|
|
|
|
|
|
|
const likeClickhandler = useCallback(async() => {
|
|
const likeClickhandler = useCallback(async() => {
|
|
|
|
|
+ const { isGuestUser } = appContainer;
|
|
|
if (isGuestUser) {
|
|
if (isGuestUser) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -64,7 +66,6 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
|
|
|
}
|
|
}
|
|
|
}, [bookmarkInfo]);
|
|
}, [bookmarkInfo]);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
if (pageInfoError != null || pageInfo == null) {
|
|
if (pageInfoError != null || pageInfo == null) {
|
|
|
return <></>;
|
|
return <></>;
|
|
|
}
|
|
}
|
|
@@ -73,17 +74,16 @@ const SubNavButtons: FC<SubNavButtonsProps> = (props: SubNavButtonsProps) => {
|
|
|
return <></>;
|
|
return <></>;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const { sumOfLikers, likerIds, isLiked } = pageInfo;
|
|
|
|
|
|
|
+ const { sumOfLikers, isLiked } = pageInfo;
|
|
|
const { sumOfBookmarks, isBookmarked } = bookmarkInfo;
|
|
const { sumOfBookmarks, isBookmarked } = bookmarkInfo;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
{isViewMode && (
|
|
{isViewMode && (
|
|
|
<PageReactionButtons
|
|
<PageReactionButtons
|
|
|
- pageId={pageId}
|
|
|
|
|
sumOfLikers={sumOfLikers}
|
|
sumOfLikers={sumOfLikers}
|
|
|
- likerIds={likerIds}
|
|
|
|
|
isLiked={isLiked}
|
|
isLiked={isLiked}
|
|
|
|
|
+ likers={likers || []}
|
|
|
onLikeClicked={likeClickhandler}
|
|
onLikeClicked={likeClickhandler}
|
|
|
sumOfBookmarks={sumOfBookmarks}
|
|
sumOfBookmarks={sumOfBookmarks}
|
|
|
isBookmarked={isBookmarked}
|
|
isBookmarked={isBookmarked}
|