|
|
@@ -4,6 +4,7 @@ import { toastError } from '../../client/util/apiNotification';
|
|
|
import { apiv3Put } from '../../client/util/apiv3-client';
|
|
|
|
|
|
import { IPageInfo, isExistPageInfo } from '~/interfaces/page';
|
|
|
+import { SubscriptionStatusType } from '~/interfaces/subscription';
|
|
|
|
|
|
import { useSWRxPageInfo } from '../../stores/page';
|
|
|
import { useSWRBookmarkInfo } from '../../stores/bookmark';
|
|
|
@@ -13,11 +14,12 @@ import { useIsGuestUser } from '~/stores/context';
|
|
|
import SubscribeButton from '../SubscribeButton';
|
|
|
import LikeButtons from '../LikeButtons';
|
|
|
import BookmarkButtons from '../BookmarkButtons';
|
|
|
-import { SubscriptionStatusType } from '~/interfaces/subscription';
|
|
|
+import SeenUserInfo from '../User/SeenUserInfo';
|
|
|
|
|
|
|
|
|
type CommonProps = {
|
|
|
isCompactMode?: boolean,
|
|
|
+ disableSeenUserInfoPopover?: boolean,
|
|
|
showPageControlDropdown?: boolean,
|
|
|
}
|
|
|
|
|
|
@@ -28,16 +30,23 @@ type SubNavButtonsSubstanceProps= CommonProps & {
|
|
|
|
|
|
const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element => {
|
|
|
const {
|
|
|
- pageInfo, pageId, isCompactMode, showPageControlDropdown,
|
|
|
+ pageInfo, pageId, isCompactMode, disableSeenUserInfoPopover, showPageControlDropdown,
|
|
|
} = props;
|
|
|
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
|
|
|
const { mutate: mutatePageInfo } = useSWRxPageInfo(pageId);
|
|
|
|
|
|
- const { data: likers } = useSWRxUsersList(pageInfo.likerIds);
|
|
|
const { data: bookmarkInfo, error: bookmarkInfoError, mutate: mutateBookmarkInfo } = useSWRBookmarkInfo(pageId, true);
|
|
|
|
|
|
+ const likerIds = pageInfo.likerIds != null ? pageInfo.likerIds.slice(0, 15) : [];
|
|
|
+ const seenUserIds = pageInfo.seenUserIds != null ? pageInfo.seenUserIds.slice(0, 15) : [];
|
|
|
+
|
|
|
+ // Put in a mixture of seenUserIds and likerIds data to make the cache work
|
|
|
+ const { data: usersList } = useSWRxUsersList([...likerIds, ...seenUserIds]);
|
|
|
+ const likers = usersList != null ? usersList.filter(({ _id }) => likerIds.includes(_id)).slice(0, 15) : [];
|
|
|
+ const seenUsers = usersList != null ? usersList.filter(({ _id }) => seenUserIds.includes(_id)).slice(0, 15) : [];
|
|
|
+
|
|
|
const subscribeClickhandler = useCallback(async() => {
|
|
|
if (isGuestUser == null || isGuestUser) {
|
|
|
return;
|
|
|
@@ -113,6 +122,7 @@ const SubNavButtonsSubstance = (props: SubNavButtonsSubstanceProps): JSX.Element
|
|
|
bookmarkedUsers={bookmarkedUsers}
|
|
|
onBookMarkClicked={bookmarkClickHandler}
|
|
|
/>
|
|
|
+ <SeenUserInfo seenUsers={seenUsers} disabled={disableSeenUserInfoPopover} />
|
|
|
{ showPageControlDropdown && (
|
|
|
/*
|
|
|
TODO:
|