phase 4: migrate account flows, trending queries, notifications, and report subjects off the bridge
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import {useMemo} from 'react'
|
||||
import {setPersonalDetails} from '@bsky.app/sdk'
|
||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {restrictChatSettings} from '#/state/queries/messages/restrictChatSettings'
|
||||
import {preferencesQueryKey} from '#/state/queries/preferences'
|
||||
import {useAgent, usePdsClient, useSession} from '#/state/session'
|
||||
import {usePdsClient, useSession} from '#/state/session'
|
||||
import {usePatchAgeAssuranceOtherRequiredData} from '#/ageAssurance'
|
||||
import {isUnderAge} from '#/ageAssurance/util'
|
||||
import {IS_DEV} from '#/env'
|
||||
@@ -54,14 +55,14 @@ export function useIsBirthdateUpdateAllowed() {
|
||||
|
||||
export function useBirthdateMutation() {
|
||||
const queryClient = useQueryClient()
|
||||
const agent = useAgent()
|
||||
const {currentAccount} = useSession()
|
||||
const pdsClient = usePdsClient()
|
||||
const patchOtherRequiredData = usePatchAgeAssuranceOtherRequiredData()
|
||||
|
||||
return useMutation<void, unknown, {birthDate: Date}>({
|
||||
mutationFn: async ({birthDate}: {birthDate: Date}) => {
|
||||
const bday = birthDate.toISOString()
|
||||
await agent.setPersonalDetails({birthDate: bday})
|
||||
await pdsClient.call(setPersonalDetails, {birthDate})
|
||||
// triggers a refetch
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: preferencesQueryKey,
|
||||
@@ -80,7 +81,9 @@ export function useBirthdateMutation() {
|
||||
* birthdate, which may change the user's age assurance access level.
|
||||
*/
|
||||
void patchOtherRequiredData({birthdate: bday})
|
||||
snoozeBirthdateUpdateAllowedForDid(agent.sessionManager.did!)
|
||||
if (currentAccount) {
|
||||
snoozeBirthdateUpdateAllowedForDid(currentAccount.did)
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user