mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-07 21:45:00 -05:00
fix: still work w/ no metadata
This commit is contained in:
parent
4b05dc2149
commit
554bd0c5f3
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@ -164,7 +164,7 @@ export default function CustomFilePage({
|
||||
|
||||
await user?.update({
|
||||
unsafeMetadata: {
|
||||
...user.unsafeMetadata,
|
||||
...(user.unsafeMetadata ?? {}),
|
||||
customFiles: metadata,
|
||||
},
|
||||
});
|
||||
|
||||
@ -119,7 +119,7 @@ export default function ServerListModificationFrame() {
|
||||
files.splice(i, 1);
|
||||
await user?.update({
|
||||
unsafeMetadata: {
|
||||
...user.unsafeMetadata,
|
||||
...(user.unsafeMetadata ?? {}),
|
||||
customFiles: files,
|
||||
},
|
||||
});
|
||||
|
||||
@ -133,7 +133,7 @@ export function CustomTestSuccess({
|
||||
|
||||
await user?.update({
|
||||
unsafeMetadata: {
|
||||
...user.unsafeMetadata,
|
||||
...(user.unsafeMetadata ?? {}),
|
||||
activatedModifications: array,
|
||||
},
|
||||
});
|
||||
|
||||
@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
@ -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<ClerkCustomModification>) ?? []),
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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<typeof useMHSFServer> }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
export function ServerEditorProvider({
|
||||
children,
|
||||
serverData,
|
||||
}: {
|
||||
children: ReactNode | ReactNode[];
|
||||
serverData: ReturnType<typeof useMHSFServer>;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener("open-server-editor", () => setOpen(true));
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
window.addEventListener("open-server-editor", () => setOpen(true));
|
||||
}, []);
|
||||
|
||||
return <>
|
||||
{children}
|
||||
<MilkdownProvider>
|
||||
<Drawer open={open} onOpenChange={setOpen}>
|
||||
<DrawerContent className="p-4 ">
|
||||
{serverData.server?.customizationData.isOwnedByUser ? <div className="h-full overflow-y-scroll">
|
||||
|
||||
<DrawerTitle className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-4xl mb-3">
|
||||
Server Settings
|
||||
</DrawerTitle>
|
||||
<Material className="grid gap-1 max-h-[700px]">
|
||||
<strong>Server Description</strong>
|
||||
<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>
|
||||
{!serverData.loading && <ServerEditorDescription 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>
|
||||
</>
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
<MilkdownProvider>
|
||||
<Drawer open={open} onOpenChange={setOpen}>
|
||||
<DrawerContent className="p-4 ">
|
||||
{serverData.server?.customizationData.isOwnedByUser ? (
|
||||
<div className="h-full overflow-y-scroll">
|
||||
<DrawerTitle className="scroll-m-20 text-2xl font-extrabold tracking-tight lg:text-4xl mb-3">
|
||||
Server Settings
|
||||
</DrawerTitle>
|
||||
<Material className="grid gap-1 max-h-[700px]">
|
||||
<strong>Server Description</strong>
|
||||
<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>
|
||||
{!serverData.loading && (
|
||||
<ServerEditorDescription
|
||||
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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user