Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
229
useEditAvatar.ts1.26 kB
import { useEffect, useState } from "react"; import { toast } from "sonner"; import { useAccountGetAvatar } from "@/api/openapi-client/accounts"; import { ProfileReference } from "@/api/openapi-schema"; import { useSession } from "@/auth"; import { useProfileMutations } from "@/lib/profile/mutation"; import { UseDisclosureProps } from "@/utils/useDisclosure"; export type Props = UseDisclosureProps & { profile: ProfileReference; }; export function useEditAvatar(props: Props) { const session = useSession(); const { revalidate } = useProfileMutations(props.profile.handle); const { data, error } = useAccountGetAvatar(session?.handle ?? ""); const [initialValue, setInitialValue] = useState<File | undefined>(undefined); useEffect(() => { (async () => { if (!data) return; const file = new File([data], "avatar.png"); setInitialValue(file); })(); }, [data]); if (!data) { return { ready: false as const, error, }; } function handleSave() { revalidate(); props.onClose?.(); toast.success("Avatar updated!", { description: "It may take a while to update across the site.", }); } return { ready: true as const, initialValue, handleSave, }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server