feat: creating list processor

This commit is contained in:
2025-10-05 15:02:12 +01:00
parent 64abf79f9c
commit 9948d2521b
8 changed files with 53 additions and 41 deletions

View File

@@ -9,7 +9,7 @@ export const ProcessingImages: Component = () => {
const processingNumber = () =>
Object.keys(notifications.state.ProcessingImages).length +
Object.keys(notifications.state.ProcessingLists).length;
Object.keys(notifications.state.ProcessingStacks).length;
const [accessToken] = createResource(getAccessToken)
@@ -60,13 +60,13 @@ export const ProcessingImages: Component = () => {
)}
</For>
<For each={Object.entries(notifications.state.ProcessingLists)}>
{([, _list]) => (
<Show when={_list}>
{(list) => (
<For each={Object.entries(notifications.state.ProcessingStacks)}>
{([, _stack]) => (
<Show when={_stack}>
{(stack) => (
<div class="flex gap-2 w-full justify-center">
<div class="flex flex-col gap-1">
<p class="text-slate-900">New Stack: {list().Name}</p>
<p class="text-slate-900">New Stack: {stack().Name}</p>
</div>
<LoadingCircle
status="loading"

View File

@@ -22,7 +22,7 @@ type NotificationState = {
string,
InferOutput<typeof processingImagesValidator> | undefined
>;
ProcessingLists: Record<
ProcessingStacks: Record<
string,
InferOutput<typeof processingListValidator> | undefined
>;
@@ -31,7 +31,7 @@ type NotificationState = {
export const Notifications = (onCompleteImage: () => void) => {
const [state, setState] = createStore<NotificationState>({
ProcessingImages: {},
ProcessingLists: {},
ProcessingStacks: {},
});
const { userImages } = useSearchImageContext();
@@ -71,14 +71,14 @@ export const Notifications = (onCompleteImage: () => void) => {
} else {
setState("ProcessingImages", ImageID, notification.output);
}
} else if (notification.output.Type === "list") {
const { ListID, Status } = notification.output;
} else if (notification.output.Type === "stack") {
const { StackID, Status } = notification.output;
if (Status === "complete") {
setState("ProcessingLists", ListID, undefined);
setState("ProcessingStacks", StackID, undefined);
onCompleteImage();
} else {
setState("ProcessingLists", ListID, notification.output);
setState("ProcessingStacks", StackID, notification.output);
}
}
};

View File

@@ -1,31 +1,31 @@
import { literal, pipe, strictObject, string, union, uuid } from "valibot";
export const processingListValidator = strictObject({
Type: literal("list"),
Type: literal("stack"),
Name: string(),
ListID: pipe(string(), uuid()),
Name: string(),
StackID: pipe(string(), uuid()),
Status: union([
literal("not-started"),
literal("in-progress"),
literal("complete"),
]),
Status: union([
literal("not-started"),
literal("in-progress"),
literal("complete"),
]),
});
export const processingImagesValidator = strictObject({
Type: literal("image"),
Type: literal("image"),
ImageID: pipe(string(), uuid()),
ImageName: string(),
Status: union([
literal("not-started"),
literal("in-progress"),
literal("complete"),
]),
ImageID: pipe(string(), uuid()),
ImageName: string(),
Status: union([
literal("not-started"),
literal("in-progress"),
literal("complete"),
]),
});
export const notificationValidator = union([
processingListValidator,
processingImagesValidator,
processingListValidator,
processingImagesValidator,
]);