better handling of empty lists
This commit is contained in:
@ -104,10 +104,10 @@ func (m UserModel) ListWithImages(ctx context.Context, userId uuid.UUID) ([]List
|
|||||||
).
|
).
|
||||||
FROM(
|
FROM(
|
||||||
Lists.
|
Lists.
|
||||||
INNER_JOIN(ImageLists, ImageLists.ListID.EQ(Lists.ID)).
|
|
||||||
INNER_JOIN(Schemas, Schemas.ListID.EQ(Lists.ID)).
|
INNER_JOIN(Schemas, Schemas.ListID.EQ(Lists.ID)).
|
||||||
INNER_JOIN(SchemaItems, SchemaItems.SchemaID.EQ(Schemas.ID)).
|
INNER_JOIN(SchemaItems, SchemaItems.SchemaID.EQ(Schemas.ID)).
|
||||||
INNER_JOIN(ImageSchemaItems, ImageSchemaItems.ImageID.EQ(ImageLists.ImageID)),
|
LEFT_JOIN(ImageLists, ImageLists.ListID.EQ(Lists.ID)).
|
||||||
|
LEFT_JOIN(ImageSchemaItems, ImageSchemaItems.ImageID.EQ(ImageLists.ImageID)),
|
||||||
).
|
).
|
||||||
WHERE(Lists.UserID.EQ(UUID(userId)))
|
WHERE(Lists.UserID.EQ(UUID(userId)))
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
type Component,
|
type Component,
|
||||||
type ParentProps,
|
type ParentProps,
|
||||||
createContext,
|
createContext,
|
||||||
|
createEffect,
|
||||||
createMemo,
|
createMemo,
|
||||||
createResource,
|
createResource,
|
||||||
useContext,
|
useContext,
|
||||||
@ -29,6 +30,10 @@ const SearchImageContext = createContext<SearchImageStore>();
|
|||||||
export const SearchImageContextProvider: Component<ParentProps> = (props) => {
|
export const SearchImageContextProvider: Component<ParentProps> = (props) => {
|
||||||
const [data, { refetch }] = createResource(getUserImages);
|
const [data, { refetch }] = createResource(getUserImages);
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
console.log(data());
|
||||||
|
});
|
||||||
|
|
||||||
const sortedImages = createMemo<ReturnType<SearchImageStore["imagesByDate"]>>(
|
const sortedImages = createMemo<ReturnType<SearchImageStore["imagesByDate"]>>(
|
||||||
() => {
|
() => {
|
||||||
const d = data();
|
const d = data();
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
pipe,
|
pipe,
|
||||||
strictObject,
|
strictObject,
|
||||||
string,
|
string,
|
||||||
|
transform,
|
||||||
union,
|
union,
|
||||||
uuid,
|
uuid,
|
||||||
} from "valibot";
|
} from "valibot";
|
||||||
@ -127,7 +128,9 @@ const listValidator = strictObject({
|
|||||||
Name: string(),
|
Name: string(),
|
||||||
Description: nullable(string()),
|
Description: nullable(string()),
|
||||||
|
|
||||||
Images: array(
|
Images: pipe(
|
||||||
|
nullable(
|
||||||
|
array(
|
||||||
strictObject({
|
strictObject({
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
ImageID: pipe(string(), uuid()),
|
ImageID: pipe(string(), uuid()),
|
||||||
@ -142,6 +145,9 @@ const listValidator = strictObject({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
transform((n) => n ?? []),
|
||||||
|
),
|
||||||
|
|
||||||
Schema: strictObject({
|
Schema: strictObject({
|
||||||
ID: pipe(string(), uuid()),
|
ID: pipe(string(), uuid()),
|
||||||
|
Reference in New Issue
Block a user