From cd44c2dc9cf553fd787f553ef6c74a1f77d40ac0 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 10 Jan 2024 23:13:55 -0800 Subject: [PATCH] ratings toggling and displaying numbers --- .../common/Card/AudioCard/AudioCard.tsx | 6 ++++-- .../common/Card/ImageCard/ImageCard.tsx | 5 +++-- .../src/hooks/useRatings/useRatings.tsx | 15 ++++++++++++--- .../src/v2/view/pages/explore/tabs/WeightsTab.tsx | 8 +++++--- 4 files changed, 24 insertions(+), 10 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 005e48449d..0c13c0543f 100644 --- a/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx +++ b/packages/fakeyou.com/src/components/common/Card/AudioCard/AudioCard.tsx @@ -72,6 +72,8 @@ export default function AudioCard({ } } + // console.log("💎",ratings?.list[data.weight_token]); + return ( @@ -201,7 +203,7 @@ export default function AudioCard({ entityToken: data.weight_token, entityType: "model_weight", onToggle: bookmarks?.toggle, - initialToggled: bookmarks?.list[data.weight_token]?.is + initialToggled: bookmarks?.list[data.weight_token]?.maybe_bookmark_token }} /> 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 a32a8a1ef4..47e239960f 100644 --- a/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx +++ b/packages/fakeyou.com/src/components/common/Card/ImageCard/ImageCard.tsx @@ -194,7 +194,8 @@ export default function ImageCard({ busy: ratings.busyList[data.weight_token], entityToken: data.weight_token, entityType: "model_weight", - likeCount: data.likes, + likeCount: ratings?.list[data.weight_token]?.positive_rating_count || 0, + initialToggled: (ratings?.list[data.weight_token]?.rating_value || "") === "positive", onToggle: ratings?.toggle }} /> @@ -204,7 +205,7 @@ export default function ImageCard({ entityToken: data.weight_token, entityType: "model_weight", onToggle: bookmarks?.toggle, - initialToggled: bookmarks?.list[data.weight_token]?.is_bookmarked + initialToggled: bookmarks?.list[data.weight_token]?.maybe_bookmark_token }} /> diff --git a/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx b/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx index 7f00aaec96..be12ec206b 100644 --- a/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx +++ b/packages/fakeyou.com/src/hooks/useRatings/useRatings.tsx @@ -28,16 +28,25 @@ export default function useRatings() { onPass: { fetch, modLibrary: (res: any, entity_token: string, entity_type: string, lib: any) => { - return { + + let jam = { ...lib, - [entity_token]: { entity_type, rating_value: lib[entity_token].rating_value === "neutral" ? "positive" : "neutral" } + [entity_token]: { + entity_type, + rating_value: lib[entity_token].rating_value === "neutral" ? "positive" : "neutral", + positive_rating_count: res.new_positive_rating_count_for_entity + } }; + + console.log("💯",res, jam); + + return jam; } }, resultsKey: "ratings" }); - // console.log("🔮",list); + console.log("🔮",list); return { busyList, gather, list, status, toggleStatus, toggleStatusSet, toggle }; }; \ No newline at end of file diff --git a/packages/fakeyou.com/src/v2/view/pages/explore/tabs/WeightsTab.tsx b/packages/fakeyou.com/src/v2/view/pages/explore/tabs/WeightsTab.tsx index 45ed3a274f..106fb2fd26 100644 --- a/packages/fakeyou.com/src/v2/view/pages/explore/tabs/WeightsTab.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/explore/tabs/WeightsTab.tsx @@ -43,9 +43,11 @@ export default function WeightsTab() { expand: true, key: "weight_token", modLibrary: (current: any, res: any, entity_token: string) => { - // let item = res.results.find((item: any, i: number) => item.weight_token === entity_token); - // console.log("🍋", item); - return current; + let { positive_rating_count } = res.results.find((item: any, i: number) => + item.weight_token === entity_token + ).stats; + + return { ...current, positive_rating_count }; } }); setShowMasonryGrid(true);