frontend client for gemstone. decentralised workplace app
at main 1.1 kB view raw
1import { getInvitesFromConstellation } from "@/queries/get-invites-from-constellation"; 2import type { OAuthSession } from "@atproto/oauth-client"; 3import { useQuery } from "@tanstack/react-query"; 4 5// TODO: use prism instead, so that we can get the backlink, the invite, and the channel's actual record 6// and not just the strongRef. 7export const useConstellationInvitesQuery = (session: OAuthSession) => { 8 const queryKey = ["invites", session.did]; 9 return { 10 queryKey, 11 useQuery: () => 12 useQuery({ 13 queryKey, 14 queryFn: async () => { 15 return await constellationInvitesQueryFn(session); 16 }, 17 }), 18 }; 19}; 20 21const constellationInvitesQueryFn = async (session: OAuthSession) => { 22 const invites = await getInvitesFromConstellation(session.did); 23 24 if (!invites.ok) { 25 console.error("constellationInvitesQueryFn error.", invites.error); 26 throw new Error( 27 `Something went wrong while getting the user's invite records.}`, 28 ); 29 } 30 31 return invites.data; 32};