From 554bd0c5f31b356cbfb430a65954538fe33ed432 Mon Sep 17 00:00:00 2001 From: dvelo <52332868+DeveloLongScript@users.noreply.github.com> Date: Tue, 6 May 2025 21:45:58 -0500 Subject: [PATCH] fix: still work w/ no metadata --- .../modification/custom/[custom-mod]/page.tsx | 4 +- .../file/[filename]/page.tsx | 2 +- .../sl-modification-frame/files/page.tsx | 2 +- .../custom-files/custom-test-success.tsx | 2 +- .../modification/modification-action.tsx | 4 +- .../modification-file-creation-dialog.tsx | 2 +- .../feat/server-page/embeds/embed-creator.tsx | 1 - .../server-editor/server-editor-provider.tsx | 82 ++++++++++++------- 8 files changed, 61 insertions(+), 38 deletions(-) diff --git a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/category/[category]/modification/custom/[custom-mod]/page.tsx b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/category/[category]/modification/custom/[custom-mod]/page.tsx index 68f39bd..2e71e5c 100644 --- a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/category/[category]/modification/custom/[custom-mod]/page.tsx +++ b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/category/[category]/modification/custom/[custom-mod]/page.tsx @@ -134,7 +134,7 @@ export default function ModificationPage({ modificationArray[modIndex] = newModObj; await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), activatedModifications: modificationArray, }, }); @@ -165,7 +165,7 @@ export default function ModificationPage({ array.splice(modIndex, 1); await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), activatedModifications: array, }, }); diff --git a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/file/[filename]/page.tsx b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/file/[filename]/page.tsx index 65d48a3..7a014fc 100644 --- a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/file/[filename]/page.tsx +++ b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/file/[filename]/page.tsx @@ -164,7 +164,7 @@ export default function CustomFilePage({ await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), customFiles: metadata, }, }); diff --git a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/files/page.tsx b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/files/page.tsx index 13cdf9b..22fc084 100644 --- a/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/files/page.tsx +++ b/apps/www/src/app/(sl-modification-frame)/servers/embedded/sl-modification-frame/files/page.tsx @@ -119,7 +119,7 @@ export default function ServerListModificationFrame() { files.splice(i, 1); await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), customFiles: files, }, }); diff --git a/apps/www/src/components/feat/server-list/modification/custom-files/custom-test-success.tsx b/apps/www/src/components/feat/server-list/modification/custom-files/custom-test-success.tsx index 0f9c1c9..38def00 100644 --- a/apps/www/src/components/feat/server-list/modification/custom-files/custom-test-success.tsx +++ b/apps/www/src/components/feat/server-list/modification/custom-files/custom-test-success.tsx @@ -133,7 +133,7 @@ export function CustomTestSuccess({ await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), activatedModifications: array, }, }); diff --git a/apps/www/src/components/feat/server-list/modification/modification-action.tsx b/apps/www/src/components/feat/server-list/modification/modification-action.tsx index 8d36f6a..bf8046e 100644 --- a/apps/www/src/components/feat/server-list/modification/modification-action.tsx +++ b/apps/www/src/components/feat/server-list/modification/modification-action.tsx @@ -83,7 +83,7 @@ export function ModificationAction({ value }: { value?: Action }) { if (existing === -1) await user.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), filters: [ { type: filter.getSpecificFilterId(), @@ -97,7 +97,7 @@ export function ModificationAction({ value }: { value?: Action }) { existingArray.splice(existing, 1); await user.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), filters: existingArray, }, }); diff --git a/apps/www/src/components/feat/server-list/modification/modification-file-creation-dialog.tsx b/apps/www/src/components/feat/server-list/modification/modification-file-creation-dialog.tsx index b0f727a..80c8522 100644 --- a/apps/www/src/components/feat/server-list/modification/modification-file-creation-dialog.tsx +++ b/apps/www/src/components/feat/server-list/modification/modification-file-creation-dialog.tsx @@ -111,7 +111,7 @@ export function ModificationFileCreationDialog({ if (!isSignedIn) return toast.error("Please login."); await user?.update({ unsafeMetadata: { - ...user.unsafeMetadata, + ...(user.unsafeMetadata ?? {}), customFiles: [ ...((user.unsafeMetadata .customFiles as Array) ?? []), diff --git a/apps/www/src/components/feat/server-page/embeds/embed-creator.tsx b/apps/www/src/components/feat/server-page/embeds/embed-creator.tsx index e9b8c6f..7da2845 100644 --- a/apps/www/src/components/feat/server-page/embeds/embed-creator.tsx +++ b/apps/www/src/components/feat/server-page/embeds/embed-creator.tsx @@ -45,7 +45,6 @@ import { useEmbedGenerator } from "@/lib/hooks/use-embed-generator"; import { cn } from "@/lib/utils"; import { EllipsisVertical } from "lucide-react"; import { useEffect, useState } from "react"; -import { ShikiRenderer } from "./embed-shiki-renderer"; import { codeToHtml } from "shiki"; import { useTheme } from "@/lib/hooks/use-theme"; import useClipboard from "@/lib/useClipboard"; diff --git a/apps/www/src/components/feat/server-page/server-editor/server-editor-provider.tsx b/apps/www/src/components/feat/server-page/server-editor/server-editor-provider.tsx index b4661fb..bc41d58 100644 --- a/apps/www/src/components/feat/server-page/server-editor/server-editor-provider.tsx +++ b/apps/www/src/components/feat/server-page/server-editor/server-editor-provider.tsx @@ -8,34 +8,58 @@ import { Material } from "@/components/ui/material"; import { Placeholder } from "@/components/ui/placeholder"; import { X } from "lucide-react"; -export function ServerEditorProvider({ children, serverData }: { children: ReactNode | ReactNode[], serverData: ReturnType }) { - const [open, setOpen] = useState(false); +export function ServerEditorProvider({ + children, + serverData, +}: { + children: ReactNode | ReactNode[]; + serverData: ReturnType; +}) { + const [open, setOpen] = useState(false); - useEffect(() => { - window.addEventListener("open-server-editor", () => setOpen(true)); - }, []) + useEffect(() => { + window.addEventListener("open-server-editor", () => setOpen(true)); + }, []); - return <> - {children} - - - - {serverData.server?.customizationData.isOwnedByUser ?
- - - Server Settings - - - Server Description -

A markdown enabled, fancy description for your server! Describe what players will expect from your server and why they should join; don't worry, you have more space than MOTD's.

- {!serverData.loading && } -
-
: } className="h-full justify-center flex items-center" title="You don't own this server" description="Unfortunately, that one ain't gonna work. Atleast not on my watch."/>} - - - -
-
-
- -} \ No newline at end of file + return ( + <> + {children} + + + + {serverData.server?.customizationData.isOwnedByUser ? ( +
+ + Server Settings + + + Server Description +

+ A markdown enabled, fancy description for your server! + Describe what players will expect from your server and why + they should join; don't worry, you have more space than + MOTD's. +

+ {!serverData.loading && ( + + )} +
+
+ ) : ( + } + className="h-full justify-center flex items-center" + title="You don't own this server" + description="Unfortunately, that one ain't gonna work. Atleast not on my watch." + /> + )} +
+
+
+ + ); +}