[Session] Add `useAgent` hook and replace (#3706)
* Hook it up * Memoize getAgent method * Use one shared reference --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>zio/stable
parent
d8c8e1e854
commit
45d354cd0c
|
@ -6,7 +6,7 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {getLabelingServiceTitle} from '#/lib/moderation'
|
import {getLabelingServiceTitle} from '#/lib/moderation'
|
||||||
import {ReportOption} from '#/lib/moderation/useReportOptions'
|
import {ReportOption} from '#/lib/moderation/useReportOptions'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a, native, useTheme} from '#/alf'
|
import {atoms as a, native, useTheme} from '#/alf'
|
||||||
|
@ -35,6 +35,7 @@ export function SubmitView({
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const [details, setDetails] = React.useState<string>('')
|
const [details, setDetails] = React.useState<string>('')
|
||||||
const [submitting, setSubmitting] = React.useState<boolean>(false)
|
const [submitting, setSubmitting] = React.useState<boolean>(false)
|
||||||
const [selectedServices, setSelectedServices] = React.useState<string[]>([
|
const [selectedServices, setSelectedServices] = React.useState<string[]>([
|
||||||
|
@ -90,6 +91,7 @@ export function SubmitView({
|
||||||
selectedServices,
|
selectedServices,
|
||||||
onSubmitComplete,
|
onSubmitComplete,
|
||||||
setError,
|
setError,
|
||||||
|
getAgent,
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {RichText as RichTextAPI} from '@atproto/api'
|
import {RichText as RichTextAPI} from '@atproto/api'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
export function useRichText(text: string): [RichTextAPI, boolean] {
|
export function useRichText(text: string): [RichTextAPI, boolean] {
|
||||||
const [prevText, setPrevText] = React.useState(text)
|
const [prevText, setPrevText] = React.useState(text)
|
||||||
const [rawRT, setRawRT] = React.useState(() => new RichTextAPI({text}))
|
const [rawRT, setRawRT] = React.useState(() => new RichTextAPI({text}))
|
||||||
const [resolvedRT, setResolvedRT] = React.useState<RichTextAPI | null>(null)
|
const [resolvedRT, setResolvedRT] = React.useState<RichTextAPI | null>(null)
|
||||||
|
const {getAgent} = useAgent()
|
||||||
if (text !== prevText) {
|
if (text !== prevText) {
|
||||||
setPrevText(text)
|
setPrevText(text)
|
||||||
setRawRT(new RichTextAPI({text}))
|
setRawRT(new RichTextAPI({text}))
|
||||||
|
@ -27,7 +28,7 @@ export function useRichText(text: string): [RichTextAPI, boolean] {
|
||||||
return () => {
|
return () => {
|
||||||
ignore = true
|
ignore = true
|
||||||
}
|
}
|
||||||
}, [text])
|
}, [text, getAgent])
|
||||||
const isResolving = resolvedRT === null
|
const isResolving = resolvedRT === null
|
||||||
return [resolvedRT ?? rawRT, isResolving]
|
return [resolvedRT ?? rawRT, isResolving]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {useLingui} from '@lingui/react'
|
||||||
import {useLabelInfo} from '#/lib/moderation/useLabelInfo'
|
import {useLabelInfo} from '#/lib/moderation/useLabelInfo'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
|
@ -173,6 +173,7 @@ function AppealForm({
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const [details, setDetails] = React.useState('')
|
const [details, setDetails] = React.useState('')
|
||||||
const isAccountReport = 'did' in subject
|
const isAccountReport = 'did' in subject
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useLingui} from '@lingui/react'
|
||||||
import {getAgent, isSessionDeactivated, useSessionApi} from '#/state/session'
|
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {pluralize} from '#/lib/strings/helpers'
|
|
||||||
|
|
||||||
import {atoms as a, useTheme, useBreakpoints} from '#/alf'
|
import {pluralize} from '#/lib/strings/helpers'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {logger} from '#/logger'
|
||||||
import {Text, P} from '#/components/Typography'
|
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
|
import {isSessionDeactivated, useAgent, useSessionApi} from '#/state/session'
|
||||||
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {ScrollView} from '#/view/com/util/Views'
|
import {ScrollView} from '#/view/com/util/Views'
|
||||||
import {Loader} from '#/components/Loader'
|
|
||||||
import {Logo} from '#/view/icons/Logo'
|
import {Logo} from '#/view/icons/Logo'
|
||||||
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
|
import {Loader} from '#/components/Loader'
|
||||||
|
import {P, Text} from '#/components/Typography'
|
||||||
|
|
||||||
const COL_WIDTH = 400
|
const COL_WIDTH = 400
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ export function Deactivated() {
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const onboardingDispatch = useOnboardingDispatch()
|
const onboardingDispatch = useOnboardingDispatch()
|
||||||
const {logout} = useSessionApi()
|
const {logout} = useSessionApi()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const [isProcessing, setProcessing] = React.useState(false)
|
const [isProcessing, setProcessing] = React.useState(false)
|
||||||
const [estimatedTime, setEstimatedTime] = React.useState<string | undefined>(
|
const [estimatedTime, setEstimatedTime] = React.useState<string | undefined>(
|
||||||
|
@ -56,7 +57,13 @@ export function Deactivated() {
|
||||||
} finally {
|
} finally {
|
||||||
setProcessing(false)
|
setProcessing(false)
|
||||||
}
|
}
|
||||||
}, [setProcessing, setEstimatedTime, setPlaceInQueue, onboardingDispatch])
|
}, [
|
||||||
|
setProcessing,
|
||||||
|
setEstimatedTime,
|
||||||
|
setPlaceInQueue,
|
||||||
|
onboardingDispatch,
|
||||||
|
getAgent,
|
||||||
|
])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
checkStatus()
|
checkStatus()
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {BSKY_APP_ACCOUNT_DID} from '#/lib/constants'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useSetSaveFeedsMutation} from '#/state/queries/preferences'
|
import {useSetSaveFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {
|
import {
|
||||||
DescriptionText,
|
DescriptionText,
|
||||||
|
@ -38,6 +38,7 @@ export function StepFinished() {
|
||||||
const onboardDispatch = useOnboardingDispatch()
|
const onboardDispatch = useOnboardingDispatch()
|
||||||
const [saving, setSaving] = React.useState(false)
|
const [saving, setSaving] = React.useState(false)
|
||||||
const {mutateAsync: saveFeeds} = useSetSaveFeedsMutation()
|
const {mutateAsync: saveFeeds} = useSetSaveFeedsMutation()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const finishOnboarding = React.useCallback(async () => {
|
const finishOnboarding = React.useCallback(async () => {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
|
@ -81,7 +82,7 @@ export function StepFinished() {
|
||||||
track('OnboardingV2:StepFinished:End')
|
track('OnboardingV2:StepFinished:End')
|
||||||
track('OnboardingV2:Complete')
|
track('OnboardingV2:Complete')
|
||||||
logEvent('onboarding:finished:nextPressed', {})
|
logEvent('onboarding:finished:nextPressed', {})
|
||||||
}, [state, dispatch, onboardDispatch, setSaving, saveFeeds, track])
|
}, [state, dispatch, onboardDispatch, setSaving, saveFeeds, track, getAgent])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
track('OnboardingV2:StepFinished:Start')
|
track('OnboardingV2:StepFinished:Start')
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {useAnalytics} from '#/lib/analytics/analytics'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {capitalize} from '#/lib/strings/capitalize'
|
import {capitalize} from '#/lib/strings/capitalize'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {
|
import {
|
||||||
DescriptionText,
|
DescriptionText,
|
||||||
|
@ -39,6 +39,7 @@ export function StepInterests() {
|
||||||
state.interestsStepResults.selectedInterests.map(i => i),
|
state.interestsStepResults.selectedInterests.map(i => i),
|
||||||
)
|
)
|
||||||
const onboardDispatch = useOnboardingDispatch()
|
const onboardDispatch = useOnboardingDispatch()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {isLoading, isError, error, data, refetch, isFetching} = useQuery({
|
const {isLoading, isError, error, data, refetch, isFetching} = useQuery({
|
||||||
queryKey: ['interests'],
|
queryKey: ['interests'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {FEEDBACK_FORM_URL} from '#/lib/constants'
|
||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {createFullHandle} from '#/lib/strings/handles'
|
import {createFullHandle} from '#/lib/strings/handles'
|
||||||
import {useServiceQuery} from '#/state/queries/service'
|
import {useServiceQuery} from '#/state/queries/service'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {LoggedOutLayout} from '#/view/com/util/layouts/LoggedOutLayout'
|
import {LoggedOutLayout} from '#/view/com/util/layouts/LoggedOutLayout'
|
||||||
import {
|
import {
|
||||||
initialState,
|
initialState,
|
||||||
|
@ -35,6 +35,7 @@ export function Signup({onPressBack}: {onPressBack: () => void}) {
|
||||||
const [state, dispatch] = React.useReducer(reducer, initialState)
|
const [state, dispatch] = React.useReducer(reducer, initialState)
|
||||||
const submit = useSubmitSignup({state, dispatch})
|
const submit = useSubmitSignup({state, dispatch})
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: serviceInfo,
|
data: serviceInfo,
|
||||||
|
@ -113,6 +114,7 @@ export function Signup({onPressBack}: {onPressBack: () => void}) {
|
||||||
state.serviceDescription?.phoneVerificationRequired,
|
state.serviceDescription?.phoneVerificationRequired,
|
||||||
state.userDomain,
|
state.userDomain,
|
||||||
submit,
|
submit,
|
||||||
|
getAgent,
|
||||||
])
|
])
|
||||||
|
|
||||||
const onBackPress = React.useCallback(() => {
|
const onBackPress = React.useCallback(() => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
import {isJustAMute} from '#/lib/moderation'
|
import {isJustAMute} from '#/lib/moderation'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {DEFAULT_LOGGED_OUT_PREFERENCES, useModerationOpts} from './preferences'
|
import {DEFAULT_LOGGED_OUT_PREFERENCES, useModerationOpts} from './preferences'
|
||||||
|
|
||||||
const DEFAULT_MOD_OPTS = {
|
const DEFAULT_MOD_OPTS = {
|
||||||
|
@ -18,6 +18,7 @@ export const RQKEY = (prefix: string) => [RQKEY_ROOT, prefix]
|
||||||
|
|
||||||
export function useActorAutocompleteQuery(prefix: string) {
|
export function useActorAutocompleteQuery(prefix: string) {
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
prefix = prefix.toLowerCase()
|
prefix = prefix.toLowerCase()
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ export type ActorAutocompleteFn = ReturnType<typeof useActorAutocompleteFn>
|
||||||
export function useActorAutocompleteFn() {
|
export function useActorAutocompleteFn() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return React.useCallback(
|
return React.useCallback(
|
||||||
async ({query, limit = 8}: {query: string; limit?: number}) => {
|
async ({query, limit = 8}: {query: string; limit?: number}) => {
|
||||||
|
@ -74,7 +76,7 @@ export function useActorAutocompleteFn() {
|
||||||
moderationOpts || DEFAULT_MOD_OPTS,
|
moderationOpts || DEFAULT_MOD_OPTS,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[queryClient, moderationOpts],
|
[queryClient, moderationOpts, getAgent],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {QueryClient, useQuery} from '@tanstack/react-query'
|
import {QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'actor-search'
|
const RQKEY_ROOT = 'actor-search'
|
||||||
export const RQKEY = (query: string) => [RQKEY_ROOT, query]
|
export const RQKEY = (query: string) => [RQKEY_ROOT, query]
|
||||||
|
@ -14,6 +14,7 @@ export function useActorSearch({
|
||||||
query: string
|
query: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyActorDefs.ProfileView[]>({
|
return useQuery<AppBskyActorDefs.ProfileView[]>({
|
||||||
staleTime: STALE.MINUTES.ONE,
|
staleTime: STALE.MINUTES.ONE,
|
||||||
queryKey: RQKEY(query || ''),
|
queryKey: RQKEY(query || ''),
|
||||||
|
|
|
@ -2,12 +2,13 @@ import {ComAtprotoServerCreateAppPassword} from '@atproto/api'
|
||||||
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '../session'
|
import {useAgent} from '../session'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'app-passwords'
|
const RQKEY_ROOT = 'app-passwords'
|
||||||
export const RQKEY = () => [RQKEY_ROOT]
|
export const RQKEY = () => [RQKEY_ROOT]
|
||||||
|
|
||||||
export function useAppPasswordsQuery() {
|
export function useAppPasswordsQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: RQKEY(),
|
queryKey: RQKEY(),
|
||||||
|
@ -20,6 +21,7 @@ export function useAppPasswordsQuery() {
|
||||||
|
|
||||||
export function useAppPasswordCreateMutation() {
|
export function useAppPasswordCreateMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
ComAtprotoServerCreateAppPassword.OutputSchema,
|
ComAtprotoServerCreateAppPassword.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
@ -42,6 +44,7 @@ export function useAppPasswordCreateMutation() {
|
||||||
|
|
||||||
export function useAppPasswordDeleteMutation() {
|
export function useAppPasswordDeleteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {name: string}>({
|
return useMutation<void, Error, {name: string}>({
|
||||||
mutationFn: async ({name}) => {
|
mutationFn: async ({name}) => {
|
||||||
await getAgent().com.atproto.server.revokeAppPassword({
|
await getAgent().com.atproto.server.revokeAppPassword({
|
||||||
|
|
|
@ -17,7 +17,7 @@ import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
|
|
||||||
export type FeedSourceFeedInfo = {
|
export type FeedSourceFeedInfo = {
|
||||||
|
@ -140,6 +140,7 @@ export function getAvatarTypeFromUri(uri: string) {
|
||||||
|
|
||||||
export function useFeedSourceInfoQuery({uri}: {uri: string}) {
|
export function useFeedSourceInfoQuery({uri}: {uri: string}) {
|
||||||
const type = getFeedTypeFromUri(uri)
|
const type = getFeedTypeFromUri(uri)
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.INFINITY,
|
staleTime: STALE.INFINITY,
|
||||||
|
@ -166,6 +167,7 @@ export function useFeedSourceInfoQuery({uri}: {uri: string}) {
|
||||||
export const useGetPopularFeedsQueryKey = ['getPopularFeeds']
|
export const useGetPopularFeedsQueryKey = ['getPopularFeeds']
|
||||||
|
|
||||||
export function useGetPopularFeedsQuery() {
|
export function useGetPopularFeedsQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema,
|
AppBskyUnspeccedGetPopularFeedGenerators.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
@ -187,6 +189,7 @@ export function useGetPopularFeedsQuery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSearchPopularFeedsMutation() {
|
export function useSearchPopularFeedsMutation() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (query: string) => {
|
mutationFn: async (query: string) => {
|
||||||
const res = await getAgent().app.bsky.unspecced.getPopularFeedGenerators({
|
const res = await getAgent().app.bsky.unspecced.getPopularFeedGenerators({
|
||||||
|
@ -238,6 +241,7 @@ const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
|
||||||
|
|
||||||
export function usePinnedFeedsInfos() {
|
export function usePinnedFeedsInfos() {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
|
const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
|
||||||
const pinnedUris = preferences?.feeds?.pinned ?? []
|
const pinnedUris = preferences?.feeds?.pinned ?? []
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const handleQueryKeyRoot = 'handle'
|
const handleQueryKeyRoot = 'handle'
|
||||||
const fetchHandleQueryKey = (handleOrDid: string) => [
|
const fetchHandleQueryKey = (handleOrDid: string) => [
|
||||||
|
@ -14,6 +14,7 @@ const fetchDidQueryKey = (handleOrDid: string) => [didQueryKeyRoot, handleOrDid]
|
||||||
|
|
||||||
export function useFetchHandle() {
|
export function useFetchHandle() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return React.useCallback(
|
return React.useCallback(
|
||||||
async (handleOrDid: string) => {
|
async (handleOrDid: string) => {
|
||||||
|
@ -27,12 +28,13 @@ export function useFetchHandle() {
|
||||||
}
|
}
|
||||||
return handleOrDid
|
return handleOrDid
|
||||||
},
|
},
|
||||||
[queryClient],
|
[queryClient, getAgent],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUpdateHandleMutation() {
|
export function useUpdateHandleMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({handle}: {handle: string}) => {
|
mutationFn: async ({handle}: {handle: string}) => {
|
||||||
|
@ -48,6 +50,7 @@ export function useUpdateHandleMutation() {
|
||||||
|
|
||||||
export function useFetchDid() {
|
export function useFetchDid() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return React.useCallback(
|
return React.useCallback(
|
||||||
async (handleOrDid: string) => {
|
async (handleOrDid: string) => {
|
||||||
|
@ -64,6 +67,6 @@ export function useFetchDid() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[queryClient],
|
[queryClient, getAgent],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
function isInviteAvailable(invite: ComAtprotoServerDefs.InviteCode): boolean {
|
function isInviteAvailable(invite: ComAtprotoServerDefs.InviteCode): boolean {
|
||||||
return invite.available - invite.uses.length > 0 && !invite.disabled
|
return invite.available - invite.uses.length > 0 && !invite.disabled
|
||||||
|
@ -16,6 +16,7 @@ export type InviteCodesQueryResponse = Exclude<
|
||||||
undefined
|
undefined
|
||||||
>
|
>
|
||||||
export function useInviteCodesQuery() {
|
export function useInviteCodesQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: [inviteCodesQueryKeyRoot],
|
queryKey: [inviteCodesQueryKeyRoot],
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {z} from 'zod'
|
||||||
import {labelersDetailedInfoQueryKeyRoot} from '#/lib/react-query'
|
import {labelersDetailedInfoQueryKeyRoot} from '#/lib/react-query'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {preferencesQueryKey} from '#/state/queries/preferences'
|
import {preferencesQueryKey} from '#/state/queries/preferences'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const labelerInfoQueryKeyRoot = 'labeler-info'
|
const labelerInfoQueryKeyRoot = 'labeler-info'
|
||||||
export const labelerInfoQueryKey = (did: string) => [
|
export const labelerInfoQueryKey = (did: string) => [
|
||||||
|
@ -31,6 +31,7 @@ export function useLabelerInfoQuery({
|
||||||
did?: string
|
did?: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: !!did && enabled !== false,
|
enabled: !!did && enabled !== false,
|
||||||
queryKey: labelerInfoQueryKey(did as string),
|
queryKey: labelerInfoQueryKey(did as string),
|
||||||
|
@ -45,6 +46,7 @@ export function useLabelerInfoQuery({
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLabelersInfoQuery({dids}: {dids: string[]}) {
|
export function useLabelersInfoQuery({dids}: {dids: string[]}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: !!dids.length,
|
enabled: !!dids.length,
|
||||||
queryKey: labelersInfoQueryKey(dids),
|
queryKey: labelersInfoQueryKey(dids),
|
||||||
|
@ -56,6 +58,7 @@ export function useLabelersInfoQuery({dids}: {dids: string[]}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useLabelersDetailedInfoQuery({dids}: {dids: string[]}) {
|
export function useLabelersDetailedInfoQuery({dids}: {dids: string[]}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: !!dids.length,
|
enabled: !!dids.length,
|
||||||
queryKey: labelersDetailedInfoQueryKey(dids),
|
queryKey: labelersDetailedInfoQueryKey(dids),
|
||||||
|
@ -73,6 +76,7 @@ export function useLabelersDetailedInfoQuery({dids}: {dids: string[]}) {
|
||||||
|
|
||||||
export function useLabelerSubscriptionMutation() {
|
export function useLabelerSubscriptionMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
async mutationFn({did, subscribe}: {did: string; subscribe: boolean}) {
|
async mutationFn({did, subscribe}: {did: string; subscribe: boolean}) {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import {useMutation} from '@tanstack/react-query'
|
import {useMutation} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
export function useLikeMutation() {
|
export function useLikeMutation() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({uri, cid}: {uri: string; cid: string}) => {
|
mutationFn: async ({uri, cid}: {uri: string; cid: string}) => {
|
||||||
const res = await getAgent().like(uri, cid)
|
const res = await getAgent().like(uri, cid)
|
||||||
|
@ -12,6 +13,7 @@ export function useLikeMutation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUnlikeMutation() {
|
export function useUnlikeMutation() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({uri}: {uri: string}) => {
|
mutationFn: async ({uri}: {uri: string}) => {
|
||||||
await getAgent().deleteLike(uri)
|
await getAgent().deleteLike(uri)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -16,6 +16,7 @@ const RQKEY_ROOT = 'list-members'
|
||||||
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
||||||
|
|
||||||
export function useListMembersQuery(uri: string) {
|
export function useListMembersQuery(uri: string) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetList.OutputSchema,
|
AppBskyGraphGetList.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {RQKEY as LIST_MEMBERS_RQKEY} from '#/state/queries/list-members'
|
import {RQKEY as LIST_MEMBERS_RQKEY} from '#/state/queries/list-members'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
|
|
||||||
// sanity limit is SANITY_PAGE_LIMIT*PAGE_SIZE total records
|
// sanity limit is SANITY_PAGE_LIMIT*PAGE_SIZE total records
|
||||||
const SANITY_PAGE_LIMIT = 1000
|
const SANITY_PAGE_LIMIT = 1000
|
||||||
|
@ -40,6 +40,7 @@ export interface ListMembersip {
|
||||||
*/
|
*/
|
||||||
export function useDangerousListMembershipsQuery() {
|
export function useDangerousListMembershipsQuery() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<ListMembersip[]>({
|
return useQuery<ListMembersip[]>({
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: RQKEY(),
|
queryKey: RQKEY(),
|
||||||
|
@ -91,6 +92,7 @@ export function getMembership(
|
||||||
|
|
||||||
export function useListMembershipAddMutation() {
|
export function useListMembershipAddMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
{uri: string; cid: string},
|
{uri: string; cid: string},
|
||||||
|
@ -149,6 +151,7 @@ export function useListMembershipAddMutation() {
|
||||||
|
|
||||||
export function useListMembershipRemoveMutation() {
|
export function useListMembershipRemoveMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
void,
|
void,
|
||||||
|
|
|
@ -13,7 +13,7 @@ import chunk from 'lodash.chunk'
|
||||||
import {uploadBlob} from '#/lib/api'
|
import {uploadBlob} from '#/lib/api'
|
||||||
import {until} from '#/lib/async/until'
|
import {until} from '#/lib/async/until'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent, useSession} from '../session'
|
import {useAgent, useSession} from '../session'
|
||||||
import {invalidate as invalidateMyLists} from './my-lists'
|
import {invalidate as invalidateMyLists} from './my-lists'
|
||||||
import {RQKEY as PROFILE_LISTS_RQKEY} from './profile-lists'
|
import {RQKEY as PROFILE_LISTS_RQKEY} from './profile-lists'
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ const RQKEY_ROOT = 'list'
|
||||||
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
export const RQKEY = (uri: string) => [RQKEY_ROOT, uri]
|
||||||
|
|
||||||
export function useListQuery(uri?: string) {
|
export function useListQuery(uri?: string) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyGraphDefs.ListView, Error>({
|
return useQuery<AppBskyGraphDefs.ListView, Error>({
|
||||||
staleTime: STALE.MINUTES.ONE,
|
staleTime: STALE.MINUTES.ONE,
|
||||||
queryKey: RQKEY(uri || ''),
|
queryKey: RQKEY(uri || ''),
|
||||||
|
@ -48,6 +49,7 @@ export interface ListCreateMutateParams {
|
||||||
export function useListCreateMutation() {
|
export function useListCreateMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<{uri: string; cid: string}, Error, ListCreateMutateParams>(
|
return useMutation<{uri: string; cid: string}, Error, ListCreateMutateParams>(
|
||||||
{
|
{
|
||||||
async mutationFn({
|
async mutationFn({
|
||||||
|
@ -114,6 +116,7 @@ export interface ListMetadataMutateParams {
|
||||||
}
|
}
|
||||||
export function useListMetadataMutation() {
|
export function useListMetadataMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
{uri: string; cid: string},
|
{uri: string; cid: string},
|
||||||
|
@ -181,6 +184,7 @@ export function useListMetadataMutation() {
|
||||||
|
|
||||||
export function useListDeleteMutation() {
|
export function useListDeleteMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<void, Error, {uri: string}>({
|
return useMutation<void, Error, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
|
@ -249,6 +253,7 @@ export function useListDeleteMutation() {
|
||||||
|
|
||||||
export function useListMuteMutation() {
|
export function useListMuteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {uri: string; mute: boolean}>({
|
return useMutation<void, Error, {uri: string; mute: boolean}>({
|
||||||
mutationFn: async ({uri, mute}) => {
|
mutationFn: async ({uri, mute}) => {
|
||||||
if (mute) {
|
if (mute) {
|
||||||
|
@ -275,6 +280,7 @@ export function useListMuteMutation() {
|
||||||
|
|
||||||
export function useListBlockMutation() {
|
export function useListBlockMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {uri: string; block: boolean}>({
|
return useMutation<void, Error, {uri: string; block: boolean}>({
|
||||||
mutationFn: async ({uri, block}) => {
|
mutationFn: async ({uri, block}) => {
|
||||||
if (block) {
|
if (block) {
|
||||||
|
|
|
@ -6,13 +6,14 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'my-blocked-accounts'
|
const RQKEY_ROOT = 'my-blocked-accounts'
|
||||||
export const RQKEY = () => [RQKEY_ROOT]
|
export const RQKEY = () => [RQKEY_ROOT]
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
|
||||||
export function useMyBlockedAccountsQuery() {
|
export function useMyBlockedAccountsQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetBlocks.OutputSchema,
|
AppBskyGraphGetBlocks.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {accumulate} from '#/lib/async/accumulate'
|
import {accumulate} from '#/lib/async/accumulate'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
|
|
||||||
export type MyListsFilter =
|
export type MyListsFilter =
|
||||||
| 'all'
|
| 'all'
|
||||||
|
@ -16,6 +16,7 @@ export const RQKEY = (filter: MyListsFilter) => [RQKEY_ROOT, filter]
|
||||||
|
|
||||||
export function useMyListsQuery(filter: MyListsFilter) {
|
export function useMyListsQuery(filter: MyListsFilter) {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyGraphDefs.ListView[]>({
|
return useQuery<AppBskyGraphDefs.ListView[]>({
|
||||||
staleTime: STALE.MINUTES.ONE,
|
staleTime: STALE.MINUTES.ONE,
|
||||||
queryKey: RQKEY(filter),
|
queryKey: RQKEY(filter),
|
||||||
|
|
|
@ -6,13 +6,14 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'my-muted-accounts'
|
const RQKEY_ROOT = 'my-muted-accounts'
|
||||||
export const RQKEY = () => [RQKEY_ROOT]
|
export const RQKEY = () => [RQKEY_ROOT]
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
|
||||||
export function useMyMutedAccountsQuery() {
|
export function useMyMutedAccountsQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetMutes.OutputSchema,
|
AppBskyGraphGetMutes.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useMutedThreads} from '#/state/muted-threads'
|
import {useMutedThreads} from '#/state/muted-threads'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {STALE} from '..'
|
import {STALE} from '..'
|
||||||
import {useModerationOpts} from '../preferences'
|
import {useModerationOpts} from '../preferences'
|
||||||
import {embedViewRecordToPostView, getEmbeddedPost} from '../util'
|
import {embedViewRecordToPostView, getEmbeddedPost} from '../util'
|
||||||
|
@ -47,6 +47,7 @@ export function RQKEY() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useNotificationFeedQuery(opts?: {enabled?: boolean}) {
|
export function useNotificationFeedQuery(opts?: {enabled?: boolean}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const threadMutes = useMutedThreads()
|
const threadMutes = useMutedThreads()
|
||||||
|
|
|
@ -12,7 +12,7 @@ import BroadcastChannel from '#/lib/broadcast'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {useMutedThreads} from '#/state/muted-threads'
|
import {useMutedThreads} from '#/state/muted-threads'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {useModerationOpts} from '../preferences'
|
import {useModerationOpts} from '../preferences'
|
||||||
import {truncateAndInvalidate} from '../util'
|
import {truncateAndInvalidate} from '../util'
|
||||||
import {RQKEY as RQKEY_NOTIFS} from './feed'
|
import {RQKEY as RQKEY_NOTIFS} from './feed'
|
||||||
|
@ -46,6 +46,7 @@ const apiContext = React.createContext<ApiContext>({
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const threadMutes = useMutedThreads()
|
const threadMutes = useMutedThreads()
|
||||||
|
@ -197,7 +198,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [setNumUnread, queryClient, moderationOpts, threadMutes])
|
}, [setNumUnread, queryClient, moderationOpts, threadMutes, getAgent])
|
||||||
checkUnreadRef.current = api.checkUnread
|
checkUnreadRef.current = api.checkUnread
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyFeedPost,
|
AppBskyFeedPost,
|
||||||
AtUri,
|
AtUri,
|
||||||
|
BskyAgent,
|
||||||
ModerationDecision,
|
ModerationDecision,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {
|
import {
|
||||||
|
@ -19,7 +20,7 @@ import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
|
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {AuthorFeedAPI} from 'lib/api/feed/author'
|
import {AuthorFeedAPI} from 'lib/api/feed/author'
|
||||||
import {CustomFeedAPI} from 'lib/api/feed/custom'
|
import {CustomFeedAPI} from 'lib/api/feed/custom'
|
||||||
import {FollowingFeedAPI} from 'lib/api/feed/following'
|
import {FollowingFeedAPI} from 'lib/api/feed/following'
|
||||||
|
@ -104,6 +105,7 @@ export function usePostFeedQuery(
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const feedTuners = useFeedTuners(feedDesc)
|
const feedTuners = useFeedTuners(feedDesc)
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const enabled = opts?.enabled !== false && Boolean(moderationOpts)
|
const enabled = opts?.enabled !== false && Boolean(moderationOpts)
|
||||||
const lastRun = useRef<{
|
const lastRun = useRef<{
|
||||||
data: InfiniteData<FeedPageUnselected>
|
data: InfiniteData<FeedPageUnselected>
|
||||||
|
@ -142,6 +144,7 @@ export function usePostFeedQuery(
|
||||||
feedDesc,
|
feedDesc,
|
||||||
feedParams: params || {},
|
feedParams: params || {},
|
||||||
feedTuners,
|
feedTuners,
|
||||||
|
getAgent,
|
||||||
}),
|
}),
|
||||||
cursor: undefined,
|
cursor: undefined,
|
||||||
}
|
}
|
||||||
|
@ -372,10 +375,12 @@ function createApi({
|
||||||
feedDesc,
|
feedDesc,
|
||||||
feedParams,
|
feedParams,
|
||||||
feedTuners,
|
feedTuners,
|
||||||
|
getAgent,
|
||||||
}: {
|
}: {
|
||||||
feedDesc: FeedDescriptor
|
feedDesc: FeedDescriptor
|
||||||
feedParams: FeedParams
|
feedParams: FeedParams
|
||||||
feedTuners: FeedTunerFn[]
|
feedTuners: FeedTunerFn[]
|
||||||
|
getAgent: () => BskyAgent
|
||||||
}) {
|
}) {
|
||||||
if (feedDesc === 'home') {
|
if (feedDesc === 'home') {
|
||||||
if (feedParams.mergeFeedEnabled) {
|
if (feedParams.mergeFeedEnabled) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -16,6 +16,7 @@ const RQKEY_ROOT = 'liked-by'
|
||||||
export const RQKEY = (resolvedUri: string) => [RQKEY_ROOT, resolvedUri]
|
export const RQKEY = (resolvedUri: string) => [RQKEY_ROOT, resolvedUri]
|
||||||
|
|
||||||
export function useLikedByQuery(resolvedUri: string | undefined) {
|
export function useLikedByQuery(resolvedUri: string | undefined) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedGetLikes.OutputSchema,
|
AppBskyFeedGetLikes.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -16,6 +16,7 @@ const RQKEY_ROOT = 'post-reposted-by'
|
||||||
export const RQKEY = (resolvedUri: string) => [RQKEY_ROOT, resolvedUri]
|
export const RQKEY = (resolvedUri: string) => [RQKEY_ROOT, resolvedUri]
|
||||||
|
|
||||||
export function usePostRepostedByQuery(resolvedUri: string | undefined) {
|
export function usePostRepostedByQuery(resolvedUri: string | undefined) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedGetRepostedBy.OutputSchema,
|
AppBskyFeedGetRepostedBy.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
import {QueryClient, useQuery, useQueryClient} from '@tanstack/react-query'
|
import {QueryClient, useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from 'state/queries/search-posts'
|
import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from 'state/queries/search-posts'
|
||||||
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from './notifications/feed'
|
import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from './notifications/feed'
|
||||||
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from './post-feed'
|
import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from './post-feed'
|
||||||
|
@ -66,6 +66,7 @@ export type ThreadNode =
|
||||||
|
|
||||||
export function usePostThreadQuery(uri: string | undefined) {
|
export function usePostThreadQuery(uri: string | undefined) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<ThreadNode, Error>({
|
return useQuery<ThreadNode, Error>({
|
||||||
gcTime: 0,
|
gcTime: 0,
|
||||||
queryKey: RQKEY(uri || ''),
|
queryKey: RQKEY(uri || ''),
|
||||||
|
|
|
@ -7,13 +7,14 @@ import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue'
|
||||||
import {logEvent, LogEvents, toClout} from '#/lib/statsig/statsig'
|
import {logEvent, LogEvents, toClout} from '#/lib/statsig/statsig'
|
||||||
import {updatePostShadow} from '#/state/cache/post-shadow'
|
import {updatePostShadow} from '#/state/cache/post-shadow'
|
||||||
import {Shadow} from '#/state/cache/types'
|
import {Shadow} from '#/state/cache/types'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {findProfileQueryData} from './profile'
|
import {findProfileQueryData} from './profile'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'post'
|
const RQKEY_ROOT = 'post'
|
||||||
export const RQKEY = (postUri: string) => [RQKEY_ROOT, postUri]
|
export const RQKEY = (postUri: string) => [RQKEY_ROOT, postUri]
|
||||||
|
|
||||||
export function usePostQuery(uri: string | undefined) {
|
export function usePostQuery(uri: string | undefined) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyFeedDefs.PostView>({
|
return useQuery<AppBskyFeedDefs.PostView>({
|
||||||
queryKey: RQKEY(uri || ''),
|
queryKey: RQKEY(uri || ''),
|
||||||
async queryFn() {
|
async queryFn() {
|
||||||
|
@ -30,6 +31,7 @@ export function usePostQuery(uri: string | undefined) {
|
||||||
|
|
||||||
export function useGetPost() {
|
export function useGetPost() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useCallback(
|
return useCallback(
|
||||||
async ({uri}: {uri: string}) => {
|
async ({uri}: {uri: string}) => {
|
||||||
return queryClient.fetchQuery({
|
return queryClient.fetchQuery({
|
||||||
|
@ -56,7 +58,7 @@ export function useGetPost() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[queryClient],
|
[queryClient, getAgent],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +127,7 @@ function usePostLikeMutation(
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const postAuthor = post.author
|
const postAuthor = post.author
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
{uri: string}, // responds with the uri of the like
|
{uri: string}, // responds with the uri of the like
|
||||||
Error,
|
Error,
|
||||||
|
@ -162,6 +165,7 @@ function usePostLikeMutation(
|
||||||
function usePostUnlikeMutation(
|
function usePostUnlikeMutation(
|
||||||
logContext: LogEvents['post:unlike']['logContext'],
|
logContext: LogEvents['post:unlike']['logContext'],
|
||||||
) {
|
) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {postUri: string; likeUri: string}>({
|
return useMutation<void, Error, {postUri: string; likeUri: string}>({
|
||||||
mutationFn: ({likeUri}) => {
|
mutationFn: ({likeUri}) => {
|
||||||
logEvent('post:unlike', {logContext})
|
logEvent('post:unlike', {logContext})
|
||||||
|
@ -234,6 +238,7 @@ export function usePostRepostMutationQueue(
|
||||||
function usePostRepostMutation(
|
function usePostRepostMutation(
|
||||||
logContext: LogEvents['post:repost']['logContext'],
|
logContext: LogEvents['post:repost']['logContext'],
|
||||||
) {
|
) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<
|
return useMutation<
|
||||||
{uri: string}, // responds with the uri of the repost
|
{uri: string}, // responds with the uri of the repost
|
||||||
Error,
|
Error,
|
||||||
|
@ -252,6 +257,7 @@ function usePostRepostMutation(
|
||||||
function usePostUnrepostMutation(
|
function usePostUnrepostMutation(
|
||||||
logContext: LogEvents['post:unrepost']['logContext'],
|
logContext: LogEvents['post:unrepost']['logContext'],
|
||||||
) {
|
) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {postUri: string; repostUri: string}>({
|
return useMutation<void, Error, {postUri: string; repostUri: string}>({
|
||||||
mutationFn: ({repostUri}) => {
|
mutationFn: ({repostUri}) => {
|
||||||
logEvent('post:unrepost', {logContext})
|
logEvent('post:unrepost', {logContext})
|
||||||
|
@ -265,6 +271,7 @@ function usePostUnrepostMutation(
|
||||||
|
|
||||||
export function usePostDeleteMutation() {
|
export function usePostDeleteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {uri: string}>({
|
return useMutation<void, Error, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
await getAgent().deletePost(uri)
|
await getAgent().deletePost(uri)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
ThreadViewPreferences,
|
ThreadViewPreferences,
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
} from '#/state/queries/preferences/types'
|
} from '#/state/queries/preferences/types'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {saveLabelers} from '#/state/session/agent-config'
|
import {saveLabelers} from '#/state/session/agent-config'
|
||||||
|
|
||||||
export * from '#/state/queries/preferences/const'
|
export * from '#/state/queries/preferences/const'
|
||||||
|
@ -33,6 +33,7 @@ const preferencesQueryKeyRoot = 'getPreferences'
|
||||||
export const preferencesQueryKey = [preferencesQueryKeyRoot]
|
export const preferencesQueryKey = [preferencesQueryKeyRoot]
|
||||||
|
|
||||||
export function usePreferencesQuery() {
|
export function usePreferencesQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.SECONDS.FIFTEEN,
|
staleTime: STALE.SECONDS.FIFTEEN,
|
||||||
structuralSharing: true,
|
structuralSharing: true,
|
||||||
|
@ -118,6 +119,7 @@ export function useModerationOpts() {
|
||||||
|
|
||||||
export function useClearPreferencesMutation() {
|
export function useClearPreferencesMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
@ -131,6 +133,7 @@ export function useClearPreferencesMutation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePreferencesSetContentLabelMutation() {
|
export function usePreferencesSetContentLabelMutation() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<
|
||||||
|
@ -150,6 +153,7 @@ export function usePreferencesSetContentLabelMutation() {
|
||||||
|
|
||||||
export function useSetContentLabelMutation() {
|
export function useSetContentLabelMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async ({
|
mutationFn: async ({
|
||||||
|
@ -172,6 +176,7 @@ export function useSetContentLabelMutation() {
|
||||||
|
|
||||||
export function usePreferencesSetAdultContentMutation() {
|
export function usePreferencesSetAdultContentMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {enabled: boolean}>({
|
return useMutation<void, unknown, {enabled: boolean}>({
|
||||||
mutationFn: async ({enabled}) => {
|
mutationFn: async ({enabled}) => {
|
||||||
|
@ -186,6 +191,7 @@ export function usePreferencesSetAdultContentMutation() {
|
||||||
|
|
||||||
export function usePreferencesSetBirthDateMutation() {
|
export function usePreferencesSetBirthDateMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {birthDate: Date}>({
|
return useMutation<void, unknown, {birthDate: Date}>({
|
||||||
mutationFn: async ({birthDate}: {birthDate: Date}) => {
|
mutationFn: async ({birthDate}: {birthDate: Date}) => {
|
||||||
|
@ -200,6 +206,7 @@ export function usePreferencesSetBirthDateMutation() {
|
||||||
|
|
||||||
export function useSetFeedViewPreferencesMutation() {
|
export function useSetFeedViewPreferencesMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, Partial<BskyFeedViewPreference>>({
|
return useMutation<void, unknown, Partial<BskyFeedViewPreference>>({
|
||||||
mutationFn: async prefs => {
|
mutationFn: async prefs => {
|
||||||
|
@ -214,6 +221,7 @@ export function useSetFeedViewPreferencesMutation() {
|
||||||
|
|
||||||
export function useSetThreadViewPreferencesMutation() {
|
export function useSetThreadViewPreferencesMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, Partial<ThreadViewPreferences>>({
|
return useMutation<void, unknown, Partial<ThreadViewPreferences>>({
|
||||||
mutationFn: async prefs => {
|
mutationFn: async prefs => {
|
||||||
|
@ -228,6 +236,7 @@ export function useSetThreadViewPreferencesMutation() {
|
||||||
|
|
||||||
export function useSetSaveFeedsMutation() {
|
export function useSetSaveFeedsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<
|
||||||
void,
|
void,
|
||||||
|
@ -246,6 +255,7 @@ export function useSetSaveFeedsMutation() {
|
||||||
|
|
||||||
export function useSaveFeedMutation() {
|
export function useSaveFeedMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
|
@ -261,6 +271,7 @@ export function useSaveFeedMutation() {
|
||||||
|
|
||||||
export function useRemoveFeedMutation() {
|
export function useRemoveFeedMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
|
@ -276,6 +287,7 @@ export function useRemoveFeedMutation() {
|
||||||
|
|
||||||
export function usePinFeedMutation() {
|
export function usePinFeedMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
|
@ -291,6 +303,7 @@ export function usePinFeedMutation() {
|
||||||
|
|
||||||
export function useUnpinFeedMutation() {
|
export function useUnpinFeedMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, {uri: string}>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async ({uri}) => {
|
||||||
|
@ -306,6 +319,7 @@ export function useUnpinFeedMutation() {
|
||||||
|
|
||||||
export function useUpsertMutedWordsMutation() {
|
export function useUpsertMutedWordsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (mutedWords: AppBskyActorDefs.MutedWord[]) => {
|
mutationFn: async (mutedWords: AppBskyActorDefs.MutedWord[]) => {
|
||||||
|
@ -320,6 +334,7 @@ export function useUpsertMutedWordsMutation() {
|
||||||
|
|
||||||
export function useUpdateMutedWordMutation() {
|
export function useUpdateMutedWordMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (mutedWord: AppBskyActorDefs.MutedWord) => {
|
mutationFn: async (mutedWord: AppBskyActorDefs.MutedWord) => {
|
||||||
|
@ -334,6 +349,7 @@ export function useUpdateMutedWordMutation() {
|
||||||
|
|
||||||
export function useRemoveMutedWordMutation() {
|
export function useRemoveMutedWordMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: async (mutedWord: AppBskyActorDefs.MutedWord) => {
|
mutationFn: async (mutedWord: AppBskyActorDefs.MutedWord) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {AppBskyFeedGetActorFeeds} from '@atproto/api'
|
import {AppBskyFeedGetActorFeeds} from '@atproto/api'
|
||||||
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -15,6 +15,7 @@ export function useProfileFeedgensQuery(
|
||||||
opts?: {enabled?: boolean},
|
opts?: {enabled?: boolean},
|
||||||
) {
|
) {
|
||||||
const enabled = opts?.enabled !== false
|
const enabled = opts?.enabled !== false
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedGetActorFeeds.OutputSchema,
|
AppBskyFeedGetActorFeeds.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -15,6 +15,7 @@ const RQKEY_ROOT = 'profile-followers'
|
||||||
export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
||||||
|
|
||||||
export function useProfileFollowersQuery(did: string | undefined) {
|
export function useProfileFollowersQuery(did: string | undefined) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetFollowers.OutputSchema,
|
AppBskyGraphGetFollowers.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -17,6 +17,7 @@ const RQKEY_ROOT = 'profile-follows'
|
||||||
export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
||||||
|
|
||||||
export function useProfileFollowsQuery(did: string | undefined) {
|
export function useProfileFollowsQuery(did: string | undefined) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetFollows.OutputSchema,
|
AppBskyGraphGetFollows.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {AppBskyGraphGetLists} from '@atproto/api'
|
import {AppBskyGraphGetLists} from '@atproto/api'
|
||||||
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
@ -11,6 +11,7 @@ export const RQKEY = (did: string) => [RQKEY_ROOT, did]
|
||||||
|
|
||||||
export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
|
export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
|
||||||
const enabled = opts?.enabled !== false
|
const enabled = opts?.enabled !== false
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphGetLists.OutputSchema,
|
AppBskyGraphGetLists.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -26,7 +26,7 @@ import {Shadow} from '#/state/cache/types'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
||||||
import {updateProfileShadow} from '../cache/profile-shadow'
|
import {updateProfileShadow} from '../cache/profile-shadow'
|
||||||
import {getAgent, useSession} from '../session'
|
import {useAgent, useSession} from '../session'
|
||||||
import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
|
import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
|
||||||
import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
|
import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
|
||||||
import {ThreadNode} from './post-thread'
|
import {ThreadNode} from './post-thread'
|
||||||
|
@ -54,6 +54,7 @@ export function useProfileQuery({
|
||||||
staleTime?: number
|
staleTime?: number
|
||||||
}) {
|
}) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyActorDefs.ProfileViewDetailed>({
|
return useQuery<AppBskyActorDefs.ProfileViewDetailed>({
|
||||||
// WARNING
|
// WARNING
|
||||||
// this staleTime is load-bearing
|
// this staleTime is load-bearing
|
||||||
|
@ -78,6 +79,7 @@ export function useProfileQuery({
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useProfilesQuery({handles}: {handles: string[]}) {
|
export function useProfilesQuery({handles}: {handles: string[]}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: profilesQueryKey(handles),
|
queryKey: profilesQueryKey(handles),
|
||||||
|
@ -89,6 +91,7 @@ export function useProfilesQuery({handles}: {handles: string[]}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePrefetchProfileQuery() {
|
export function usePrefetchProfileQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const prefetchProfileQuery = useCallback(
|
const prefetchProfileQuery = useCallback(
|
||||||
async (did: string) => {
|
async (did: string) => {
|
||||||
|
@ -100,7 +103,7 @@ export function usePrefetchProfileQuery() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[queryClient],
|
[queryClient, getAgent],
|
||||||
)
|
)
|
||||||
return prefetchProfileQuery
|
return prefetchProfileQuery
|
||||||
}
|
}
|
||||||
|
@ -116,6 +119,7 @@ interface ProfileUpdateParams {
|
||||||
}
|
}
|
||||||
export function useProfileUpdateMutation() {
|
export function useProfileUpdateMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, ProfileUpdateParams>({
|
return useMutation<void, Error, ProfileUpdateParams>({
|
||||||
mutationFn: async ({
|
mutationFn: async ({
|
||||||
profile,
|
profile,
|
||||||
|
@ -257,6 +261,7 @@ function useProfileFollowMutation(
|
||||||
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>,
|
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>,
|
||||||
) {
|
) {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}) => {
|
||||||
|
@ -283,6 +288,7 @@ function useProfileFollowMutation(
|
||||||
function useProfileUnfollowMutation(
|
function useProfileUnfollowMutation(
|
||||||
logContext: LogEvents['profile:unfollow']['logContext'],
|
logContext: LogEvents['profile:unfollow']['logContext'],
|
||||||
) {
|
) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {did: string; followUri: string}>({
|
return useMutation<void, Error, {did: string; followUri: string}>({
|
||||||
mutationFn: async ({followUri}) => {
|
mutationFn: async ({followUri}) => {
|
||||||
logEvent('profile:unfollow', {logContext})
|
logEvent('profile:unfollow', {logContext})
|
||||||
|
@ -343,6 +349,7 @@ export function useProfileMuteMutationQueue(
|
||||||
|
|
||||||
function useProfileMuteMutation() {
|
function useProfileMuteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {did: string}>({
|
return useMutation<void, Error, {did: string}>({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}) => {
|
||||||
await getAgent().mute(did)
|
await getAgent().mute(did)
|
||||||
|
@ -355,6 +362,7 @@ function useProfileMuteMutation() {
|
||||||
|
|
||||||
function useProfileUnmuteMutation() {
|
function useProfileUnmuteMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useMutation<void, Error, {did: string}>({
|
return useMutation<void, Error, {did: string}>({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}) => {
|
||||||
await getAgent().unmute(did)
|
await getAgent().unmute(did)
|
||||||
|
@ -421,6 +429,7 @@ export function useProfileBlockMutationQueue(
|
||||||
|
|
||||||
function useProfileBlockMutation() {
|
function useProfileBlockMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
return useMutation<{uri: string; cid: string}, Error, {did: string}>({
|
||||||
mutationFn: async ({did}) => {
|
mutationFn: async ({did}) => {
|
||||||
|
@ -441,6 +450,7 @@ function useProfileBlockMutation() {
|
||||||
|
|
||||||
function useProfileUnblockMutation() {
|
function useProfileUnblockMutation() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
return useMutation<void, Error, {did: string; blockUri: string}>({
|
return useMutation<void, Error, {did: string; blockUri: string}>({
|
||||||
mutationFn: async ({blockUri}) => {
|
mutationFn: async ({blockUri}) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import {AppBskyActorDefs, AtUri} from '@atproto/api'
|
||||||
import {useQuery, useQueryClient, UseQueryResult} from '@tanstack/react-query'
|
import {useQuery, useQueryClient, UseQueryResult} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {profileBasicQueryKey as RQKEY_PROFILE_BASIC} from './profile'
|
import {profileBasicQueryKey as RQKEY_PROFILE_BASIC} from './profile'
|
||||||
|
|
||||||
const RQKEY_ROOT = 'resolved-did'
|
const RQKEY_ROOT = 'resolved-did'
|
||||||
|
@ -24,6 +24,7 @@ export function useResolveUriQuery(uri: string | undefined): UriUseQueryResult {
|
||||||
|
|
||||||
export function useResolveDidQuery(didOrHandle: string | undefined) {
|
export function useResolveDidQuery(didOrHandle: string | undefined) {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useQuery<string, Error>({
|
return useQuery<string, Error>({
|
||||||
staleTime: STALE.HOURS.ONE,
|
staleTime: STALE.HOURS.ONE,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
||||||
|
|
||||||
const searchPostsQueryKeyRoot = 'search-posts'
|
const searchPostsQueryKeyRoot = 'search-posts'
|
||||||
|
@ -25,6 +25,7 @@ export function useSearchPostsQuery({
|
||||||
sort?: 'top' | 'latest'
|
sort?: 'top' | 'latest'
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedSearchPosts.OutputSchema,
|
AppBskyFeedSearchPosts.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -2,12 +2,13 @@ import {AppBskyFeedGetSuggestedFeeds} from '@atproto/api'
|
||||||
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
import {InfiniteData, QueryKey, useInfiniteQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
const suggestedFeedsQueryKeyRoot = 'suggestedFeeds'
|
const suggestedFeedsQueryKeyRoot = 'suggestedFeeds'
|
||||||
export const suggestedFeedsQueryKey = [suggestedFeedsQueryKeyRoot]
|
export const suggestedFeedsQueryKey = [suggestedFeedsQueryKeyRoot]
|
||||||
|
|
||||||
export function useSuggestedFeedsQuery() {
|
export function useSuggestedFeedsQuery() {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedGetSuggestedFeeds.OutputSchema,
|
AppBskyFeedGetSuggestedFeeds.OutputSchema,
|
||||||
Error,
|
Error,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {useModerationOpts} from '#/state/queries/preferences'
|
import {useModerationOpts} from '#/state/queries/preferences'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
|
|
||||||
const suggestedFollowsQueryKeyRoot = 'suggested-follows'
|
const suggestedFollowsQueryKeyRoot = 'suggested-follows'
|
||||||
const suggestedFollowsQueryKey = [suggestedFollowsQueryKeyRoot]
|
const suggestedFollowsQueryKey = [suggestedFollowsQueryKeyRoot]
|
||||||
|
@ -27,6 +27,7 @@ const suggestedFollowsByActorQueryKey = (did: string) => [
|
||||||
|
|
||||||
export function useSuggestedFollowsQuery() {
|
export function useSuggestedFollowsQuery() {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
|
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
|
@ -77,6 +78,7 @@ export function useSuggestedFollowsQuery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSuggestedFollowsByActorQuery({did}: {did: string}) {
|
export function useSuggestedFollowsByActorQuery({did}: {did: string}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
return useQuery<AppBskyGraphGetSuggestedFollowsByActor.OutputSchema, Error>({
|
return useQuery<AppBskyGraphGetSuggestedFollowsByActor.OutputSchema, Error>({
|
||||||
queryKey: suggestedFollowsByActorQueryKey(did),
|
queryKey: suggestedFollowsByActorQueryKey(did),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
|
|
@ -23,16 +23,14 @@ import {readLabelers} from './agent-config'
|
||||||
|
|
||||||
let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
|
let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
|
||||||
|
|
||||||
/**
|
function __getAgent() {
|
||||||
* NOTE
|
|
||||||
* Never hold on to the object returned by this function.
|
|
||||||
* Call `getAgent()` at the time of invocation to ensure
|
|
||||||
* that you never have a stale agent.
|
|
||||||
*/
|
|
||||||
export function getAgent() {
|
|
||||||
return __globalAgent
|
return __globalAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useAgent() {
|
||||||
|
return React.useMemo(() => ({getAgent: __getAgent}), [])
|
||||||
|
}
|
||||||
|
|
||||||
export type SessionAccount = persisted.PersistedAccount
|
export type SessionAccount = persisted.PersistedAccount
|
||||||
|
|
||||||
export type SessionState = {
|
export type SessionState = {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import {
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
import {Gif} from '#/state/queries/tenor'
|
import {Gif} from '#/state/queries/tenor'
|
||||||
import {ThreadgateSetting} from '#/state/queries/threadgate'
|
import {ThreadgateSetting} from '#/state/queries/threadgate'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {useAnalytics} from 'lib/analytics/analytics'
|
import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
import * as apilib from 'lib/api/index'
|
import * as apilib from 'lib/api/index'
|
||||||
|
@ -83,6 +83,7 @@ export const ComposePost = observer(function ComposePost({
|
||||||
imageUris: initImageUris,
|
imageUris: initImageUris,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {data: currentProfile} = useProfileQuery({did: currentAccount!.did})
|
const {data: currentProfile} = useProfileQuery({did: currentAccount!.did})
|
||||||
const {isModalActive} = useModals()
|
const {isModalActive} = useModals()
|
||||||
const {closeComposer} = useComposerControls()
|
const {closeComposer} = useComposerControls()
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import {useState, useEffect} from 'react'
|
import {useEffect, useState} from 'react'
|
||||||
|
|
||||||
|
import {useAgent} from '#/state/session'
|
||||||
import * as apilib from 'lib/api/index'
|
import * as apilib from 'lib/api/index'
|
||||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||||
import {ComposerOpts} from 'state/shell/composer'
|
import {ComposerOpts} from 'state/shell/composer'
|
||||||
import {getAgent} from '#/state/session'
|
|
||||||
|
|
||||||
export function useExternalLinkFetch({}: {
|
export function useExternalLinkFetch({}: {
|
||||||
setQuote: (opts: ComposerOpts['quote']) => void
|
setQuote: (opts: ComposerOpts['quote']) => void
|
||||||
}) {
|
}) {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const [extLink, setExtLink] = useState<apilib.ExternalEmbedDraft | undefined>(
|
const [extLink, setExtLink] = useState<apilib.ExternalEmbedDraft | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
)
|
)
|
||||||
|
@ -39,7 +41,7 @@ export function useExternalLinkFetch({}: {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return cleanup
|
return cleanup
|
||||||
}, [extLink])
|
}, [extLink, getAgent])
|
||||||
|
|
||||||
return {extLink, setExtLink}
|
return {extLink, setExtLink}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
import {useState, useEffect} from 'react'
|
import {useEffect, useState} from 'react'
|
||||||
import {ImageModel} from 'state/models/media/image'
|
|
||||||
|
import {logger} from '#/logger'
|
||||||
|
import {useFetchDid} from '#/state/queries/handle'
|
||||||
|
import {useGetPost} from '#/state/queries/post'
|
||||||
|
import {useAgent} from '#/state/session'
|
||||||
import * as apilib from 'lib/api/index'
|
import * as apilib from 'lib/api/index'
|
||||||
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
import {POST_IMG_MAX} from 'lib/constants'
|
||||||
import {
|
import {
|
||||||
getPostAsQuote,
|
|
||||||
getFeedAsEmbed,
|
getFeedAsEmbed,
|
||||||
getListAsEmbed,
|
getListAsEmbed,
|
||||||
|
getPostAsQuote,
|
||||||
} from 'lib/link-meta/bsky'
|
} from 'lib/link-meta/bsky'
|
||||||
|
import {getLinkMeta} from 'lib/link-meta/link-meta'
|
||||||
import {downloadAndResize} from 'lib/media/manip'
|
import {downloadAndResize} from 'lib/media/manip'
|
||||||
import {
|
import {
|
||||||
isBskyPostUrl,
|
|
||||||
isBskyCustomFeedUrl,
|
isBskyCustomFeedUrl,
|
||||||
isBskyListUrl,
|
isBskyListUrl,
|
||||||
|
isBskyPostUrl,
|
||||||
} from 'lib/strings/url-helpers'
|
} from 'lib/strings/url-helpers'
|
||||||
|
import {ImageModel} from 'state/models/media/image'
|
||||||
import {ComposerOpts} from 'state/shell/composer'
|
import {ComposerOpts} from 'state/shell/composer'
|
||||||
import {POST_IMG_MAX} from 'lib/constants'
|
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {getAgent} from '#/state/session'
|
|
||||||
import {useGetPost} from '#/state/queries/post'
|
|
||||||
import {useFetchDid} from '#/state/queries/handle'
|
|
||||||
|
|
||||||
export function useExternalLinkFetch({
|
export function useExternalLinkFetch({
|
||||||
setQuote,
|
setQuote,
|
||||||
|
@ -30,6 +31,7 @@ export function useExternalLinkFetch({
|
||||||
)
|
)
|
||||||
const getPost = useGetPost()
|
const getPost = useGetPost()
|
||||||
const fetchDid = useFetchDid()
|
const fetchDid = useFetchDid()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let aborted = false
|
let aborted = false
|
||||||
|
@ -135,7 +137,7 @@ export function useExternalLinkFetch({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return cleanup
|
return cleanup
|
||||||
}, [extLink, setQuote, getPost, fetchDid])
|
}, [extLink, setQuote, getPost, fetchDid, getAgent])
|
||||||
|
|
||||||
return {extLink, setExtLink}
|
return {extLink, setExtLink}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
import React, {useState} from 'react'
|
import React, {useState} from 'react'
|
||||||
import {ActivityIndicator, SafeAreaView, StyleSheet, View} from 'react-native'
|
import {ActivityIndicator, SafeAreaView, StyleSheet, View} from 'react-native'
|
||||||
import {ScrollView, TextInput} from './util'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {Text} from '../util/text/Text'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Button} from '../util/forms/Button'
|
|
||||||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
import {useModalControls} from '#/state/modals'
|
||||||
import * as Toast from '../util/Toast'
|
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
||||||
import {s, colors} from 'lib/styles'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {isWeb} from 'platform/detection'
|
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
import {Trans, msg} from '@lingui/macro'
|
import {colors, s} from 'lib/styles'
|
||||||
import {useLingui} from '@lingui/react'
|
import {isWeb} from 'platform/detection'
|
||||||
import {useModalControls} from '#/state/modals'
|
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||||
import {useSession, useSessionApi, getAgent} from '#/state/session'
|
import {Button} from '../util/forms/Button'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
|
import * as Toast from '../util/Toast'
|
||||||
|
import {ScrollView, TextInput} from './util'
|
||||||
|
|
||||||
enum Stages {
|
enum Stages {
|
||||||
InputEmail,
|
InputEmail,
|
||||||
|
@ -26,6 +27,7 @@ export const snapPoints = ['90%']
|
||||||
export function Component() {
|
export function Component() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
const {updateCurrentAccount} = useSessionApi()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [stage, setStage] = useState<Stages>(Stages.InputEmail)
|
const [stage, setStage] = useState<Stages>(Stages.InputEmail)
|
||||||
|
|
|
@ -16,8 +16,8 @@ import {useModalControls} from '#/state/modals'
|
||||||
import {useFetchDid, useUpdateHandleMutation} from '#/state/queries/handle'
|
import {useFetchDid, useUpdateHandleMutation} from '#/state/queries/handle'
|
||||||
import {useServiceQuery} from '#/state/queries/service'
|
import {useServiceQuery} from '#/state/queries/service'
|
||||||
import {
|
import {
|
||||||
getAgent,
|
|
||||||
SessionAccount,
|
SessionAccount,
|
||||||
|
useAgent,
|
||||||
useSession,
|
useSession,
|
||||||
useSessionApi,
|
useSessionApi,
|
||||||
} from '#/state/session'
|
} from '#/state/session'
|
||||||
|
@ -40,6 +40,7 @@ export type Props = {onChanged: () => void}
|
||||||
|
|
||||||
export function Component(props: Props) {
|
export function Component(props: Props) {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {
|
const {
|
||||||
isLoading,
|
isLoading,
|
||||||
data: serviceInfo,
|
data: serviceInfo,
|
||||||
|
|
|
@ -6,24 +6,25 @@ import {
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {ScrollView} from './util'
|
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {TextInput} from './util'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {Text} from '../util/text/Text'
|
import {useLingui} from '@lingui/react'
|
||||||
import {Button} from '../util/forms/Button'
|
import * as EmailValidator from 'email-validator'
|
||||||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
|
||||||
import {s, colors} from 'lib/styles'
|
import {logger} from '#/logger'
|
||||||
|
import {useModalControls} from '#/state/modals'
|
||||||
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {isAndroid, isWeb} from 'platform/detection'
|
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError, isNetworkError} from 'lib/strings/errors'
|
import {cleanError, isNetworkError} from 'lib/strings/errors'
|
||||||
import {checkAndFormatResetCode} from 'lib/strings/password'
|
import {checkAndFormatResetCode} from 'lib/strings/password'
|
||||||
import {Trans, msg} from '@lingui/macro'
|
import {colors, s} from 'lib/styles'
|
||||||
import {useLingui} from '@lingui/react'
|
import {isAndroid, isWeb} from 'platform/detection'
|
||||||
import {useModalControls} from '#/state/modals'
|
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||||
import {useSession, getAgent} from '#/state/session'
|
import {Button} from '../util/forms/Button'
|
||||||
import * as EmailValidator from 'email-validator'
|
import {Text} from '../util/text/Text'
|
||||||
import {logger} from '#/logger'
|
import {ScrollView} from './util'
|
||||||
|
import {TextInput} from './util'
|
||||||
|
|
||||||
enum Stages {
|
enum Stages {
|
||||||
RequestCode,
|
RequestCode,
|
||||||
|
@ -36,6 +37,7 @@ export const snapPoints = isAndroid ? ['90%'] : ['45%']
|
||||||
export function Component() {
|
export function Component() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [stage, setStage] = useState<Stages>(Stages.RequestCode)
|
const [stage, setStage] = useState<Stages>(Stages.RequestCode)
|
||||||
const [isProcessing, setIsProcessing] = useState<boolean>(false)
|
const [isProcessing, setIsProcessing] = useState<boolean>(false)
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
useListCreateMutation,
|
useListCreateMutation,
|
||||||
useListMetadataMutation,
|
useListMetadataMutation,
|
||||||
} from '#/state/queries/list'
|
} from '#/state/queries/list'
|
||||||
import {getAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {useAnalytics} from 'lib/analytics/analytics'
|
import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
|
@ -62,6 +62,7 @@ export function Component({
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const listCreateMutation = useListCreateMutation()
|
const listCreateMutation = useListCreateMutation()
|
||||||
const listMetadataMutation = useListMetadataMutation()
|
const listMetadataMutation = useListMetadataMutation()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const activePurpose = useMemo(() => {
|
const activePurpose = useMemo(() => {
|
||||||
if (list?.purpose) {
|
if (list?.purpose) {
|
||||||
|
@ -228,6 +229,7 @@ export function Component({
|
||||||
listMetadataMutation,
|
listMetadataMutation,
|
||||||
listCreateMutation,
|
listCreateMutation,
|
||||||
_,
|
_,
|
||||||
|
getAgent,
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {getAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
|
@ -30,6 +30,7 @@ export function Component({}: {}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {clearCurrentAccount, removeAccount} = useSessionApi()
|
const {clearCurrentAccount, removeAccount} = useSessionApi()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {closeModal} = useModalControls()
|
const {closeModal} = useModalControls()
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {getAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
|
@ -41,6 +41,7 @@ export function Component({
|
||||||
onSuccess?: () => void
|
onSuccess?: () => void
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
const {updateCurrentAccount} = useSessionApi()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
|
@ -19,7 +19,7 @@ import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
||||||
import {useModerationOpts} from '#/state/queries/preferences'
|
import {useModerationOpts} from '#/state/queries/preferences'
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
|
import {useResolveDidQuery} from '#/state/queries/resolve-uri'
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {useSetDrawerSwipeDisabled, useSetMinimalShellMode} from '#/state/shell'
|
import {useSetDrawerSwipeDisabled, useSetMinimalShellMode} from '#/state/shell'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {useAnalytics} from 'lib/analytics/analytics'
|
import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
|
@ -472,6 +472,7 @@ function ProfileScreenLoaded({
|
||||||
}
|
}
|
||||||
|
|
||||||
function useRichText(text: string): [RichTextAPI, boolean] {
|
function useRichText(text: string): [RichTextAPI, boolean] {
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const [prevText, setPrevText] = React.useState(text)
|
const [prevText, setPrevText] = React.useState(text)
|
||||||
const [rawRT, setRawRT] = React.useState(() => new RichTextAPI({text}))
|
const [rawRT, setRawRT] = React.useState(() => new RichTextAPI({text}))
|
||||||
const [resolvedRT, setResolvedRT] = React.useState<RichTextAPI | null>(null)
|
const [resolvedRT, setResolvedRT] = React.useState<RichTextAPI | null>(null)
|
||||||
|
@ -495,7 +496,7 @@ function useRichText(text: string): [RichTextAPI, boolean] {
|
||||||
return () => {
|
return () => {
|
||||||
ignore = true
|
ignore = true
|
||||||
}
|
}
|
||||||
}, [text])
|
}, [text, getAgent])
|
||||||
const isResolving = resolvedRT === null
|
const isResolving = resolvedRT === null
|
||||||
return [resolvedRT ?? rawRT, isResolving]
|
return [resolvedRT ?? rawRT, isResolving]
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {getAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
||||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
|
@ -31,6 +31,7 @@ export function DisableEmail2FADialog({
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
const {updateCurrentAccount} = useSessionApi()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const [stage, setStage] = useState<Stages>(Stages.Email)
|
const [stage, setStage] = useState<Stages>(Stages.Email)
|
||||||
const [confirmationCode, setConfirmationCode] = useState<string>('')
|
const [confirmationCode, setConfirmationCode] = useState<string>('')
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {getAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
||||||
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {DisableEmail2FADialog} from './DisableEmail2FADialog'
|
import {DisableEmail2FADialog} from './DisableEmail2FADialog'
|
||||||
|
@ -14,6 +14,7 @@ export function Email2FAToggle() {
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
const {updateCurrentAccount} = useSessionApi()
|
||||||
const {openModal} = useModalControls()
|
const {openModal} = useModalControls()
|
||||||
const disableDialogCtrl = useDialogControl()
|
const disableDialogCtrl = useDialogControl()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const enableEmailAuthFactor = React.useCallback(async () => {
|
const enableEmailAuthFactor = React.useCallback(async () => {
|
||||||
if (currentAccount?.email) {
|
if (currentAccount?.email) {
|
||||||
|
@ -25,7 +26,7 @@ export function Email2FAToggle() {
|
||||||
emailAuthFactor: true,
|
emailAuthFactor: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [currentAccount, updateCurrentAccount])
|
}, [currentAccount, updateCurrentAccount, getAgent])
|
||||||
|
|
||||||
const onToggle = React.useCallback(() => {
|
const onToggle = React.useCallback(() => {
|
||||||
if (!currentAccount) {
|
if (!currentAccount) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {View} from 'react-native'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonText} from '#/components/Button'
|
import {Button, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
@ -19,6 +19,7 @@ export function ExportCarDialog({
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const downloadUrl = React.useMemo(() => {
|
const downloadUrl = React.useMemo(() => {
|
||||||
const agent = getAgent()
|
const agent = getAgent()
|
||||||
|
@ -30,7 +31,7 @@ export function ExportCarDialog({
|
||||||
url.pathname = '/xrpc/com.atproto.sync.getRepo'
|
url.pathname = '/xrpc/com.atproto.sync.getRepo'
|
||||||
url.searchParams.set('did', agent.session.did)
|
url.searchParams.set('did', agent.session.did)
|
||||||
return url.toString()
|
return url.toString()
|
||||||
}, [currentAccount])
|
}, [currentAccount, getAgent])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control}>
|
||||||
|
|
|
@ -13,7 +13,7 @@ import * as NavigationBar from 'expo-navigation-bar'
|
||||||
import {StatusBar} from 'expo-status-bar'
|
import {StatusBar} from 'expo-status-bar'
|
||||||
import {useNavigationState} from '@react-navigation/native'
|
import {useNavigationState} from '@react-navigation/native'
|
||||||
|
|
||||||
import {getAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {
|
import {
|
||||||
useIsDrawerOpen,
|
useIsDrawerOpen,
|
||||||
useIsDrawerSwipeDisabled,
|
useIsDrawerSwipeDisabled,
|
||||||
|
@ -57,6 +57,7 @@ function ShellInner() {
|
||||||
)
|
)
|
||||||
const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
|
const canGoBack = useNavigationState(state => !isStateAtTabRoot(state))
|
||||||
const {hasSession, currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
const closeAnyActiveElement = useCloseAnyActiveElement()
|
const closeAnyActiveElement = useCloseAnyActiveElement()
|
||||||
const {importantForAccessibility} = useDialogStateContext()
|
const {importantForAccessibility} = useDialogStateContext()
|
||||||
// start undefined
|
// start undefined
|
||||||
|
@ -85,7 +86,7 @@ function ShellInner() {
|
||||||
)
|
)
|
||||||
return unsub
|
return unsub
|
||||||
}
|
}
|
||||||
}, [currentAccount])
|
}, [currentAccount, getAgent])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
Loading…
Reference in New Issue