From 0cdf113e296c4160042b351dabdb5293fab627c3 Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 13 Feb 2024 16:36:05 -0800 Subject: [PATCH] fixed bookmarks/likes on bookmarks + crash on bookmarks --- .../components/common/Card/AudioCard/AudioCard.tsx | 2 +- .../components/common/Card/ImageCard/ImageCard.tsx | 2 +- .../src/hooks/useBatchContent/useBatchContent.tsx | 3 ++- .../fakeyou.com/src/hooks/useRatings/useRatings.tsx | 13 ++++++++++--- .../profile/profile_view/tabs/BookmarksTab.tsx | 6 +++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx b/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx index 6344ea1ca3..476a5a96c6 100644 --- a/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx +++ b/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx @@ -182,7 +182,7 @@ export default function AudioCard({ {...{ creator: data?.creator || data.details.maybe_weight_data?.maybe_creator, - entityToken: data.weight_token, + entityToken: data.weight_token || data.details?.entity_token, entityType: "model_weight", makeBookmarksProps: bookmarks?.makeProps, makeRatingsProps: ratings?.makeProps, diff --git a/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx b/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx index dd4680c3fd..77d63fa7d5 100644 --- a/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx +++ b/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx @@ -184,7 +184,7 @@ export default function ImageCard({ creator: data.creator || data.details.maybe_weight_data?.maybe_creator, - entityToken: data.weight_token, + entityToken: data.weight_token || data.details?.entity_token, entityType: "model_weight", makeBookmarksProps: bookmarks?.makeProps, makeRatingsProps: ratings?.makeProps, diff --git a/packages/fakeyou.com/src/hooks/useBatchContent/useBatchContent.tsx b/packages/fakeyou.com/src/hooks/useBatchContent/useBatchContent.tsx index 3d6e08885b..122df522e7 100644 --- a/packages/fakeyou.com/src/hooks/useBatchContent/useBatchContent.tsx +++ b/packages/fakeyou.com/src/hooks/useBatchContent/useBatchContent.tsx @@ -57,7 +57,8 @@ export default function useBatchContent({ const dlog = (...dbg: any) => debug ? console.log(...dbg) : {}; const gather = ({ expand, key, res }: Gather) => { - let tokens = res.results ? res.results.map((item: any) => item[key]) : [res[key]]; + let tokens = res.results ? res.results.map((item: any) => item.details[key] || item[key]) : [res[key]]; + // console.log("😎",tokens); let abc = tokens.reduce((obj = {},token = "") => ({ ...obj, [token]: true }),{}) dlog("🪙",fetcher); tokenTypeSet(key) diff --git a/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx b/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx index 7e2167eaa3..e72622b0a7 100644 --- a/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx +++ b/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx @@ -34,9 +34,16 @@ export default function useRatings() { checker: () => true, // debug: "useRatings", modLibrary: (current: any, res: any, entity_token: string, tokenType: string) => { - let { positive_rating_count } = res.results ? res.results.find((item: any, i: number) => - item[tokenType] === entity_token - ).stats : res.stats; + + let result = res.results ? res.results.find((item: any, i: number) => + { + return item.details[tokenType] === entity_token || item[tokenType] === entity_token + } + ) : res; + + let { positive_rating_count } = result.details.stats || result.stats; + + // let { positive_rating_count } = res.results ? itemMatch.details.stats || itemMatch.details.stats return { ...current, positive_rating_count }; }, diff --git a/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/BookmarksTab.tsx b/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/BookmarksTab.tsx index 38a8d19475..056c5cc874 100644 --- a/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/BookmarksTab.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/profile/profile_view/tabs/BookmarksTab.tsx @@ -58,8 +58,8 @@ export default function BookmarksTab({ username }: { username: string }) { listSet, onInputChange: () => setShowMasonryGrid(false), onSuccess: res => { - bookmarks.gather({ res, key: "weight_token" }); - ratings.gather({ res, key: "weight_token" }); + bookmarks.gather({ res, key: "entity_token" }); + ratings.gather({ res, key: "entity_token" }); setShowMasonryGrid(true); }, requestList: true, @@ -236,7 +236,7 @@ export default function BookmarksTab({ username }: { username: string }) { >