fix: still work w/ no metadata

This commit is contained in:
dvelo 2025-05-06 21:45:58 -05:00
parent 4b05dc2149
commit 554bd0c5f3
8 changed files with 61 additions and 38 deletions

@ -134,7 +134,7 @@ export default function ModificationPage({
modificationArray[modIndex] = newModObj; modificationArray[modIndex] = newModObj;
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
activatedModifications: modificationArray, activatedModifications: modificationArray,
}, },
}); });
@ -165,7 +165,7 @@ export default function ModificationPage({
array.splice(modIndex, 1); array.splice(modIndex, 1);
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
activatedModifications: array, activatedModifications: array,
}, },
}); });

@ -164,7 +164,7 @@ export default function CustomFilePage({
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
customFiles: metadata, customFiles: metadata,
}, },
}); });

@ -119,7 +119,7 @@ export default function ServerListModificationFrame() {
files.splice(i, 1); files.splice(i, 1);
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
customFiles: files, customFiles: files,
}, },
}); });

@ -133,7 +133,7 @@ export function CustomTestSuccess({
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
activatedModifications: array, activatedModifications: array,
}, },
}); });

@ -83,7 +83,7 @@ export function ModificationAction({ value }: { value?: Action }) {
if (existing === -1) if (existing === -1)
await user.update({ await user.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
filters: [ filters: [
{ {
type: filter.getSpecificFilterId(), type: filter.getSpecificFilterId(),
@ -97,7 +97,7 @@ export function ModificationAction({ value }: { value?: Action }) {
existingArray.splice(existing, 1); existingArray.splice(existing, 1);
await user.update({ await user.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
filters: existingArray, filters: existingArray,
}, },
}); });

@ -111,7 +111,7 @@ export function ModificationFileCreationDialog({
if (!isSignedIn) return toast.error("Please login."); if (!isSignedIn) return toast.error("Please login.");
await user?.update({ await user?.update({
unsafeMetadata: { unsafeMetadata: {
...user.unsafeMetadata, ...(user.unsafeMetadata ?? {}),
customFiles: [ customFiles: [
...((user.unsafeMetadata ...((user.unsafeMetadata
.customFiles as Array<ClerkCustomModification>) ?? []), .customFiles as Array<ClerkCustomModification>) ?? []),

@ -45,7 +45,6 @@ import { useEmbedGenerator } from "@/lib/hooks/use-embed-generator";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { EllipsisVertical } from "lucide-react"; import { EllipsisVertical } from "lucide-react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { ShikiRenderer } from "./embed-shiki-renderer";
import { codeToHtml } from "shiki"; import { codeToHtml } from "shiki";
import { useTheme } from "@/lib/hooks/use-theme"; import { useTheme } from "@/lib/hooks/use-theme";
import useClipboard from "@/lib/useClipboard"; import useClipboard from "@/lib/useClipboard";

@ -8,34 +8,58 @@ import { Material } from "@/components/ui/material";
import { Placeholder } from "@/components/ui/placeholder"; import { Placeholder } from "@/components/ui/placeholder";
import { X } from "lucide-react"; import { X } from "lucide-react";
export function ServerEditorProvider({ children, serverData }: { children: ReactNode | ReactNode[], serverData: ReturnType<typeof useMHSFServer> }) { export function ServerEditorProvider({
const [open, setOpen] = useState(false); children,
serverData,
}: {
children: ReactNode | ReactNode[];
serverData: ReturnType<typeof useMHSFServer>;
}) {
const [open, setOpen] = useState(false);
useEffect(() => { useEffect(() => {
window.addEventListener("open-server-editor", () => setOpen(true)); window.addEventListener("open-server-editor", () => setOpen(true));
}, []) }, []);
return <> return (
{children} <>
<MilkdownProvider> {children}
<Drawer open={open} onOpenChange={setOpen}> <MilkdownProvider>
<DrawerContent className="p-4 "> <Drawer open={open} onOpenChange={setOpen}>
{serverData.server?.customizationData.isOwnedByUser ? <div className="h-full overflow-y-scroll"> <DrawerContent className="p-4 ">
{serverData.server?.customizationData.isOwnedByUser ? (
<DrawerTitle className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-4xl mb-3"> <div className="h-full overflow-y-scroll">
Server Settings <DrawerTitle className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-4xl mb-3">
</DrawerTitle> Server Settings
<Material className="grid gap-1 max-h-[700px]"> </DrawerTitle>
<strong>Server Description</strong> <Material className="grid gap-1 max-h-[700px]">
<p className="mb-3">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.</p> <strong>Server Description</strong>
{!serverData.loading && <ServerEditorDescription defaultMarkdown={serverData.server?.customizationData.description ?? ""} />} <p className="mb-3">
</Material> A markdown enabled, fancy description for your server!
</div> : <Placeholder icon={<X />} 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."/>} Describe what players will expect from your server and why
they should join; don't worry, you have more space than
MOTD's.
</p>
</DrawerContent> {!serverData.loading && (
</Drawer> <ServerEditorDescription
</MilkdownProvider> defaultMarkdown={
</> serverData.server?.customizationData.description ?? ""
}
/>
)}
</Material>
</div>
) : (
<Placeholder
icon={<X />}
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."
/>
)}
</DrawerContent>
</Drawer>
</MilkdownProvider>
</>
);
} }