mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-14 13:52:11 +00:00
ratings toggling and displaying numbers
This commit is contained in:
1 parent
3835bab034
commit
cd44c2dc9c
4 files changed
+24
-10
No files matched your search
@@ -72,6 +72,8 @@ export default function AudioCard({
|
||||
}
|
||||
}
|
||||
|
||||
// console.log("💎",ratings?.list[data.weight_token]);
|
||||
|
||||
return (
|
||||
<Link
|
||||
{...{
|
||||
@@ -191,7 +193,7 @@ export default function AudioCard({
|
||||
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,
|
||||
onToggle: ratings?.toggle
|
||||
}} />
|
||||
</div>
|
||||
@@ -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
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
}} />
|
||||
</div>
|
||||
@@ -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
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user