Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
229
useCollectionMenu.ts1.19 kB
import { useCollectionList } from "src/api/openapi-client/collections"; import { Account, Collection, PostReference } from "src/api/openapi-schema"; import { handle } from "@/api/client"; import { useCollectionItemMutations } from "@/lib/collection/mutation"; export type Props = { account: Account; thread: PostReference; }; export function useCollectionMenu({ account, thread }: Props) { const { data, error } = useCollectionList({ account_handle: account.handle, has_item: thread.id, }); const { addPost, removePost, revalidate } = useCollectionItemMutations(account); if (!data) { return { ready: false as const, error, }; } const { collections } = data; const handleSelect = (collection: Collection) => async () => { await handle( async () => { const isAlreadySavedIn = collection?.has_queried_item; if (isAlreadySavedIn) { await removePost(collection.id, thread.id); } else { await addPost(collection, thread.id); } }, { cleanup: async () => await revalidate() }, ); }; return { ready: true as const, collections, handleSelect, }; }

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