Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at theme-changes 62 lines 1.6 kB view raw
1import {type ComAtprotoServerCreateAppPassword} from '@atproto/api' 2import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' 3 4import {STALE} from '#/state/queries' 5import {useAgent} from '../session' 6import {pdsAgent} from '../session/agent' 7 8const RQKEY_ROOT = 'app-passwords' 9export const RQKEY = () => [RQKEY_ROOT] 10 11export function useAppPasswordsQuery() { 12 const agent = useAgent() 13 return useQuery({ 14 staleTime: STALE.MINUTES.FIVE, 15 queryKey: RQKEY(), 16 queryFn: async () => { 17 const res = await pdsAgent(agent).com.atproto.server.listAppPasswords({}) 18 return res.data.passwords 19 }, 20 }) 21} 22 23export function useAppPasswordCreateMutation() { 24 const queryClient = useQueryClient() 25 const agent = useAgent() 26 return useMutation< 27 ComAtprotoServerCreateAppPassword.OutputSchema, 28 Error, 29 {name: string; privileged: boolean} 30 >({ 31 mutationFn: async ({name, privileged}) => { 32 return ( 33 await pdsAgent(agent).com.atproto.server.createAppPassword({ 34 name, 35 privileged, 36 }) 37 ).data 38 }, 39 onSuccess() { 40 queryClient.invalidateQueries({ 41 queryKey: RQKEY(), 42 }) 43 }, 44 }) 45} 46 47export function useAppPasswordDeleteMutation() { 48 const queryClient = useQueryClient() 49 const agent = useAgent() 50 return useMutation<void, Error, {name: string}>({ 51 mutationFn: async ({name}) => { 52 await pdsAgent(agent).com.atproto.server.revokeAppPassword({ 53 name, 54 }) 55 }, 56 onSuccess() { 57 queryClient.invalidateQueries({ 58 queryKey: RQKEY(), 59 }) 60 }, 61 }) 62}