wip: different UI

fix
This commit is contained in:
2025-07-02 16:24:25 +01:00
parent a65ef5f548
commit a94c7255c6
4 changed files with 235 additions and 163 deletions

View File

@@ -7,7 +7,7 @@ import {
createResource,
useContext,
} from "solid-js";
import { getUserImages } from "../network";
import { CategoryUnion, getUserImages } from "../network";
import { groupPropertiesWithImage } from "../utils/groupPropertiesWithImage";
export type ImageWithRawData = Awaited<
@@ -16,7 +16,16 @@ export type ImageWithRawData = Awaited<
rawData: string[];
};
type SearchImageStore = {
type TaggedCategory<T extends CategoryUnion["type"]> = Extract<
CategoryUnion,
{ type: T }
>["data"];
type CategoriesSpecificData = {
[K in CategoryUnion["type"]]: Array<TaggedCategory<K>>;
};
export type SearchImageStore = {
images: Accessor<ImageWithRawData[]>;
imagesWithProperties: Accessor<ReturnType<typeof groupPropertiesWithImage>>;
@@ -24,6 +33,8 @@ type SearchImageStore = {
Awaited<ReturnType<typeof getUserImages>>["ProcessingImages"] | undefined
>;
categories: Accessor<CategoriesSpecificData>;
onRefetchImages: () => void;
};
@@ -87,6 +98,25 @@ export const SearchImageContextProvider: Component<ParentProps> = (props) => {
return groupPropertiesWithImage(d);
});
const categories = createMemo(() => {
const c: ReturnType<SearchImageStore["categories"]> = {
contact: [],
event: [],
location: [],
note: [],
};
for (const category of data()?.ImageProperties ?? []) {
if (category.type === "location" || category.type === "contact") {
continue;
}
c[category.type].push(category.data as any);
}
return c;
});
return (
<SearchImageContext.Provider
value={{
@@ -94,6 +124,7 @@ export const SearchImageContextProvider: Component<ParentProps> = (props) => {
imagesWithProperties: imagesWithProperties,
processingImages,
onRefetchImages: refetch,
categories,
}}
>
{props.children}