mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-10 03:51:25 +00:00
Merge branch 'feature/mvp' into fixes/mvp1_improvements
This commit is contained in:
commit
366a9128ac
7 files changed
+24
-12
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -57,11 +57,11 @@ 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 abc = tokens.reduce((obj = {},token = "") => ({ ...obj, [token]: true }),{})
|
||||
let tokens = res.results ? res.results.map((item: any) => (item.details || item)[key]) : [res[key]];
|
||||
let loadingTokens = tokens.reduce((obj = {},token = "") => ({ ...obj, [token]: true }),{})
|
||||
dlog("🪙",fetcher);
|
||||
tokenTypeSet(key)
|
||||
busyListSet(abc); // add current batch to busy list
|
||||
busyListSet(loadingTokens); // add current batch to busy list
|
||||
fetcher("",{},{ tokens }).then((batchRes: any) => {
|
||||
|
||||
// console.log("🦄",resultsKey, res, modLibrary);
|
||||
|
||||
@@ -12,7 +12,6 @@ export default function useMedia({
|
||||
const [status, statusSet] = useState(FetchStatus.ready);
|
||||
const [writeStatus, writeStatusSet] = useState(FetchStatus.paused);
|
||||
const [media,mediaSet] = useState<MediaFile | undefined>();
|
||||
|
||||
const remove = (as_mod: boolean) => {
|
||||
writeStatusSet(FetchStatus.in_progress);
|
||||
DeleteMedia(mediaToken, {
|
||||
@@ -45,6 +44,11 @@ export default function useMedia({
|
||||
});
|
||||
}
|
||||
|
||||
if (media && media.token !== mediaToken) {
|
||||
mediaSet(undefined);
|
||||
statusSet(FetchStatus.ready);
|
||||
}
|
||||
|
||||
},[media, mediaToken, onSuccess, status, statusSet]);
|
||||
|
||||
return { media, mediaSet, remove, status, writeStatus };
|
||||
|
||||
@@ -34,9 +34,14 @@ 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 || item)[tokenType] === entity_token
|
||||
}
|
||||
) : res;
|
||||
|
||||
let { positive_rating_count } = (result.details || result).stats;
|
||||
|
||||
return { ...current, positive_rating_count };
|
||||
},
|
||||
|
||||
@@ -29,6 +29,7 @@ export default function MediaTab() {
|
||||
);
|
||||
const [showMasonryGrid, setShowMasonryGrid] = useState(true);
|
||||
const [list, listSet] = useState<MediaFile[]>([]);
|
||||
console.log("💙",list);
|
||||
const media = useLazyLists({
|
||||
addQueries: {
|
||||
page_size: 24,
|
||||
@@ -42,8 +43,10 @@ export default function MediaTab() {
|
||||
listSet,
|
||||
onInputChange: () => setShowMasonryGrid(false),
|
||||
onSuccess: res => {
|
||||
console.log("😎",res);
|
||||
ratings.gather({ res, expand: true, key: "token" }); // expand rather than replace for lazy loading
|
||||
bookmarks.gather({ res, expand: true, key: "token" }); // expand rather than replace for lazy loading
|
||||
console.log("🩵",);
|
||||
setShowMasonryGrid(true);
|
||||
},
|
||||
requestList: true,
|
||||
|
||||
@@ -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 }) {
|
||||
>
|
||||
<WeightsCards
|
||||
{...{
|
||||
type: data.details.maybe_weight_data.weight_category,
|
||||
type: data.details.maybe_weight_data?.weight_category,
|
||||
props: weightProps,
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user