From 838ab37fc1c142b5d1b3dc674ba9b0822c6b6619 Mon Sep 17 00:00:00 2001 From: John Costa Date: Sun, 5 Oct 2025 15:12:37 +0100 Subject: [PATCH] refactor: list -> stack --- backend/stacks/handler.go | 4 +- frontend/src/App.tsx | 4 +- .../{list-card => stack-card}/index.tsx | 12 ++--- frontend/src/network/index.ts | 10 ++--- frontend/src/pages/front/gallery.tsx | 38 ++++++++-------- frontend/src/pages/image/index.tsx | 4 +- frontend/src/pages/index.ts | 2 +- frontend/src/pages/{list => stack}/index.tsx | 44 +++++++++---------- 8 files changed, 59 insertions(+), 59 deletions(-) rename frontend/src/components/{list-card => stack-card}/index.tsx (57%) rename frontend/src/pages/{list => stack}/index.tsx (91%) diff --git a/backend/stacks/handler.go b/backend/stacks/handler.go index f5bbd5e..43e0c88 100644 --- a/backend/stacks/handler.go +++ b/backend/stacks/handler.go @@ -53,7 +53,7 @@ func (h *StackHandler) getStackItems(w http.ResponseWriter, r *http.Request) { return } - stackID, err := middleware.GetPathParamID(h.logger, "listID", w, r) + stackID, err := middleware.GetPathParamID(h.logger, "stackID", w, r) if err != nil { return } @@ -86,7 +86,7 @@ func (h *StackHandler) deleteStack(w http.ResponseWriter, r *http.Request) { return } - stackID, err := middleware.GetPathParamID(h.logger, "listID", w, r) + stackID, err := middleware.GetPathParamID(h.logger, "stackID", w, r) if err != nil { return } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 84de5ad..0b91085 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -7,7 +7,7 @@ import { Settings, SearchPage, AllImages, - List, + Stack, } from "./pages"; import { SearchImageContextProvider } from "@contexts/SearchImageContext"; import { WithNotifications } from "@contexts/Notifications"; @@ -41,7 +41,7 @@ export const App = () => { path="/image/:imageId" component={ImagePage} /> - + diff --git a/frontend/src/components/list-card/index.tsx b/frontend/src/components/stack-card/index.tsx similarity index 57% rename from frontend/src/components/list-card/index.tsx rename to frontend/src/components/stack-card/index.tsx index 81959f8..12dc1f7 100644 --- a/frontend/src/components/list-card/index.tsx +++ b/frontend/src/components/stack-card/index.tsx @@ -1,4 +1,4 @@ -import { List } from "@network/index"; +import { Stack } from "@network/index"; import { Component } from "solid-js"; import fastHashCode from "../../utils/hash"; import { A } from "@solidjs/router"; @@ -17,19 +17,19 @@ const colors = [ "bg-pink-50", ]; -export const StackCard: Component<{ list: List }> = (props) => { +export const StackCard: Component<{ stack: Stack }> = (props) => { return ( -

{props.list.Name}

-

{props.list.Images.length}

+

{props.stack.Name}

+

{props.stack.Images.length}

); }; diff --git a/frontend/src/network/index.ts b/frontend/src/network/index.ts index 13e009c..73fc8be 100644 --- a/frontend/src/network/index.ts +++ b/frontend/src/network/index.ts @@ -133,7 +133,7 @@ export const deleteStackItem = async ( await fetch(request); } -export const deleteList = async (listID: string): Promise => { +export const deleteStack = async (listID: string): Promise => { const request = await getBaseAuthorizedRequest({ path: `stacks/${listID}`, method: "DELETE", @@ -238,7 +238,7 @@ const stackValidator = strictObject({ SchemaItems: array(stackSchemaItem), }); -export type List = InferOutput; +export type Stack = InferOutput; const imageRequestValidator = strictObject({ UserImages: array(userImageValidator), @@ -303,13 +303,13 @@ export const postCode = async ( return parsedRes.output; }; -export class ReachedListLimit extends Error { +export class ReachedStackLimit extends Error { constructor() { super(); } } -export const createList = async ( +export const createStack = async ( title: string, description: string, ): Promise => { @@ -323,6 +323,6 @@ export const createList = async ( const res = await fetch(request); if (!res.ok && res.status == 429) { - throw new ReachedListLimit(); + throw new ReachedStackLimit(); } }; diff --git a/frontend/src/pages/front/gallery.tsx b/frontend/src/pages/front/gallery.tsx index ae8d879..5c939a5 100644 --- a/frontend/src/pages/front/gallery.tsx +++ b/frontend/src/pages/front/gallery.tsx @@ -1,10 +1,10 @@ import { Component, For, createSignal } from "solid-js"; import { useSearchImageContext } from "@contexts/SearchImageContext"; -import { StackCard } from "@components/list-card"; import { Button } from "@kobalte/core/button"; import { Dialog } from "@kobalte/core/dialog"; -import { createList, ReachedListLimit } from "../../network"; +import { createStack, ReachedStackLimit } from "../../network"; import { createToast } from "../../utils/show-toast"; +import { StackCard } from "@components/stack-card"; export const Categories: Component = () => { const { stacks, onRefetchImages } = useSearchImageContext(); @@ -15,20 +15,20 @@ export const Categories: Component = () => { const [isCreating, setIsCreating] = createSignal(false); const [showForm, setShowForm] = createSignal(false); - const handleCreateList = async () => { + const handleCreatestack = async () => { if (description().trim().length === 0 || title().trim().length === 0) return; setIsCreating(true); try { - await createList(title().trim(), description().trim()); + await createStack(title().trim(), description().trim()); setTitle(""); setDescription(""); setShowForm(false); onRefetchImages(); // Refresh the stacks } catch (error) { - console.error("Failed to create list:", error); - if (error instanceof ReachedListLimit) { + console.error("Failed to create stack:", error); + if (error instanceof ReachedStackLimit) { createToast("Reached limit!", "You've reached your limit for new stacks"); } } finally { @@ -40,7 +40,7 @@ export const Categories: Component = () => {

Generated stacks

- {(list) => } + {(stack) => }
@@ -48,7 +48,7 @@ export const Categories: Component = () => { class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition-colors font-medium shadow-sm hover:shadow-md" onClick={() => setShowForm(true)} > - + Create List + + Create stack
@@ -59,25 +59,25 @@ export const Categories: Component = () => {
- Create New List + Create New stack
setTitle(e.target.value) } - placeholder="Enter a title for your list" + placeholder="Enter a title for your stack" class="w-full p-3 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-indigo-600 focus:border-transparent transition-colors" disabled={isCreating()} /> @@ -85,18 +85,18 @@ export const Categories: Component = () => {