diff --git a/public/logo.svg b/public/logo.svg deleted file mode 100644 index 699991b..0000000 --- a/public/logo.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/components/Controlbar.tsx b/src/components/Controlbar.tsx index ba5e7d9..1e7911d 100644 --- a/src/components/Controlbar.tsx +++ b/src/components/Controlbar.tsx @@ -1,14 +1,12 @@ import { $, component$, noSerialize, NoSerialize, useSignal, useVisibleTask$ } from "@builder.io/qwik"; import { useNanostore$ } from "~/hooks/nanostores"; import { api } from "~/lib/api"; -import { areFilesLoaded, dashboardFiles } from "~/lib/stores"; +import { DashboardFiles } from "~/lib/stores"; import { StereoFile } from "~/lib/types"; -import { SolarUploadLinear, SvgSpinnersBarsRotateFade } from "./Icons"; -import StereoLogo from "./StereoLogo"; +import { SolarUploadLinear } from "./Icons"; export default component$(() => { - const loaded = useNanostore$(areFilesLoaded); - const files = useNanostore$(dashboardFiles); + const files = useNanostore$(DashboardFiles); const fileInputRef = useSignal(); const uploadingFile = useSignal | undefined>(); const now = useSignal(new Date()); @@ -27,18 +25,14 @@ export default component$(() => { } try { - const unsafe = uploadingFile.value as File; - const name = unsafe.name.replace(/[^a-zA-Z0-9_.-]/g, "_"); - const f = new File([unsafe], name, { type: unsafe.type }); - - await api.upload(f); + await api.upload(uploadingFile.value as File) files.value = await api.list(); } catch (error) { console.error("Error uploading file:", error); } }) return ( -
+
{ }} /> -
- - -

|

- +
@@ -105,7 +105,7 @@ export default component$(({ file }: FileProps) => {

- { file.Name || "Untitled" } + { file.ID.split("_").slice(1).join("_") || "Untitled" }

{ formatSize(file.Size) } diff --git a/src/components/StereoLogo.tsx b/src/components/StereoLogo.tsx deleted file mode 100644 index 892ea95..0000000 --- a/src/components/StereoLogo.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { component$, QwikIntrinsicElements } from "@builder.io/qwik"; - -export default component$((props: QwikIntrinsicElements['svg']) => { - return ( - - - - ) -}) \ No newline at end of file diff --git a/src/hooks/nanostores.ts b/src/hooks/nanostores.ts index 4a91166..3896ec4 100644 --- a/src/hooks/nanostores.ts +++ b/src/hooks/nanostores.ts @@ -10,7 +10,7 @@ import { } from "@builder.io/qwik"; import { Atom, WritableAtom } from "nanostores"; -function writeable(store: Atom | WritableAtom): store is WritableAtom { +function writeable(store: Atom | WritableAtom): store is WritableAtom { return typeof (store as WritableAtom).set === 'function'; } diff --git a/src/lib/api.ts b/src/lib/api.ts index b25f5dc..5a0eafb 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -14,7 +14,10 @@ export const api = { formData.append('file', file); return await client.post('upload', { body: formData }); }, - delete: async (uid: string, file: string) => { - return await client.delete(`${uid}/${file}`).json(); + delete: async (file_id: string) => { + console.log("Deleting file with ID:", file_id); + return await client.delete(`delete`, { + json: { file_id } + }).json(); }, } \ No newline at end of file diff --git a/src/lib/stores.ts b/src/lib/stores.ts index 444b668..dc9c0b3 100644 --- a/src/lib/stores.ts +++ b/src/lib/stores.ts @@ -1,5 +1,4 @@ import { atom } from "nanostores"; import { StereoFile } from "./types"; -export const areFilesLoaded = atom(false); -export const dashboardFiles = atom([]); \ No newline at end of file +export const DashboardFiles = atom([]); \ No newline at end of file diff --git a/src/lib/types.ts b/src/lib/types.ts index 63354f2..090fbd5 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,5 +1,5 @@ export type StereoFile = { - Name: string; + ID: string; Owner: string; CreatedAt: string; Size: number; diff --git a/src/routes/api/[...path]/index.tsx b/src/routes/api/[path]/index.tsx similarity index 100% rename from src/routes/api/[...path]/index.tsx rename to src/routes/api/[path]/index.tsx diff --git a/src/routes/index.tsx b/src/routes/index.tsx index b807745..9705b84 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -1,4 +1,4 @@ -import { component$, useVisibleTask$ } from "@builder.io/qwik"; +import { component$, useSignal, useVisibleTask$ } from "@builder.io/qwik"; import type { DocumentHead } from "@builder.io/qwik-city"; import Controlbar from "~/components/Controlbar"; import File from "~/components/File"; @@ -6,14 +6,14 @@ import { SolarUploadLinear, SvgSpinnersBarsRotateFade } from "~/components/Icons import { useNanostore$ } from "~/hooks/nanostores"; import { api } from "~/lib/api"; import { OAUTH_LINK } from "~/lib/constants"; -import { areFilesLoaded, dashboardFiles } from "~/lib/stores"; +import { DashboardFiles } from "~/lib/stores"; import { StereoFile } from "~/lib/types"; // TODO: move this to dashboard/index.tsx export default component$(() => { - const files = useNanostore$(dashboardFiles); - const loaded = useNanostore$(areFilesLoaded); + const files = useNanostore$(DashboardFiles); + const loaded = useSignal(false); useVisibleTask$(async () => { loaded.value = false; @@ -43,7 +43,7 @@ export default component$(() => { : (
{files.value.map((file) => ( - + ))}
)