Migrate to new plural APIs
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import {Insets, Platform} from 'react-native'
|
import {Insets, Platform} from 'react-native'
|
||||||
import {AppBskyActorDefs} from '@atproto/api'
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {TID} from '@atproto/common-web'
|
|
||||||
|
|
||||||
export const LOCAL_DEV_SERVICE =
|
export const LOCAL_DEV_SERVICE =
|
||||||
Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583'
|
Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583'
|
||||||
@@ -95,15 +94,16 @@ export const BSKY_FEED_OWNER_DIDS = [
|
|||||||
export const DISCOVER_FEED_URI =
|
export const DISCOVER_FEED_URI =
|
||||||
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot'
|
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot'
|
||||||
|
|
||||||
export const RECOMMENDED_SAVED_FEEDS: AppBskyActorDefs.SavedFeed[] = [
|
export const RECOMMENDED_SAVED_FEEDS: Pick<
|
||||||
|
AppBskyActorDefs.SavedFeed,
|
||||||
|
'type' | 'value' | 'pinned'
|
||||||
|
>[] = [
|
||||||
{
|
{
|
||||||
id: TID.nextStr(),
|
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
value: DISCOVER_FEED_URI,
|
value: DISCOVER_FEED_URI,
|
||||||
pinned: true,
|
pinned: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: TID.nextStr(),
|
|
||||||
type: 'timeline',
|
type: 'timeline',
|
||||||
value: 'home',
|
value: 'home',
|
||||||
pinned: true,
|
pinned: true,
|
||||||
|
|||||||
@@ -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 {useAddSavedFeedMutation} from '#/state/queries/preferences'
|
import {useAddSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {InlineLinkText} from '#/components/Link'
|
import {InlineLinkText} from '#/components/Link'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
@@ -11,22 +11,24 @@ import {Text} from '#/components/Typography'
|
|||||||
export function NoFollowingFeed() {
|
export function NoFollowingFeed() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {mutateAsync: addSavedFeed} = useAddSavedFeedMutation()
|
const {mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
|
|
||||||
const addRecommendedFeeds = React.useCallback(
|
const addRecommendedFeeds = React.useCallback(
|
||||||
(e: any) => {
|
(e: any) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
addSavedFeed({
|
addSavedFeeds([
|
||||||
type: 'timeline',
|
{
|
||||||
value: 'home',
|
type: 'timeline',
|
||||||
pinned: true,
|
value: 'home',
|
||||||
})
|
pinned: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
// prevent navigation
|
// prevent navigation
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
[addSavedFeed],
|
[addSavedFeeds],
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants'
|
import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants'
|
||||||
import {useSetSaveFeedsMutation} from '#/state/queries/preferences'
|
import {useAddSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
||||||
@@ -13,11 +13,11 @@ import {Text} from '#/components/Typography'
|
|||||||
export function NoSavedFeeds() {
|
export function NoSavedFeeds() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {isPending, mutateAsync: setSavedFeeds} = useSetSaveFeedsMutation()
|
const {isPending, mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
|
|
||||||
const addRecommendedFeeds = React.useCallback(async () => {
|
const addRecommendedFeeds = React.useCallback(async () => {
|
||||||
await setSavedFeeds(RECOMMENDED_SAVED_FEEDS)
|
await addSavedFeeds(RECOMMENDED_SAVED_FEEDS)
|
||||||
}, [setSavedFeeds])
|
}, [addSavedFeeds])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants'
|
import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants'
|
||||||
import {useSetSaveFeedsMutation} from '#/state/queries/preferences'
|
import {useAddSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {CenteredView} from '#/view/com/util/Views'
|
import {CenteredView} from '#/view/com/util/Views'
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
@@ -30,11 +30,11 @@ export function useHeaderOffset() {
|
|||||||
export function NoFeedsPinned() {
|
export function NoFeedsPinned() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const headerOffset = useHeaderOffset()
|
const headerOffset = useHeaderOffset()
|
||||||
const {isPending, mutateAsync: setSavedFeeds} = useSetSaveFeedsMutation()
|
const {isPending, mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
|
|
||||||
const addRecommendedFeeds = React.useCallback(async () => {
|
const addRecommendedFeeds = React.useCallback(async () => {
|
||||||
await setSavedFeeds(RECOMMENDED_SAVED_FEEDS)
|
await addSavedFeeds(RECOMMENDED_SAVED_FEEDS)
|
||||||
}, [setSavedFeeds])
|
}, [addSavedFeeds])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CenteredView sideBorders style={[a.h_full_vh]}>
|
<CenteredView sideBorders style={[a.h_full_vh]}>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {TID} from '@atproto/common-web'
|
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ import {useAnalytics} from '#/lib/analytics/analytics'
|
|||||||
import {BSKY_APP_ACCOUNT_DID} from '#/lib/constants'
|
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 {useAddSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {getAgent} from '#/state/session'
|
import {getAgent} from '#/state/session'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {
|
import {
|
||||||
@@ -38,7 +37,7 @@ export function StepFinished() {
|
|||||||
const {state, dispatch} = React.useContext(Context)
|
const {state, dispatch} = React.useContext(Context)
|
||||||
const onboardDispatch = useOnboardingDispatch()
|
const onboardDispatch = useOnboardingDispatch()
|
||||||
const [saving, setSaving] = React.useState(false)
|
const [saving, setSaving] = React.useState(false)
|
||||||
const {mutateAsync: saveFeeds} = useSetSaveFeedsMutation()
|
const {mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
|
|
||||||
const finishOnboarding = React.useCallback(async () => {
|
const finishOnboarding = React.useCallback(async () => {
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
@@ -63,9 +62,8 @@ export function StepFinished() {
|
|||||||
// these must be serial
|
// these must be serial
|
||||||
(async () => {
|
(async () => {
|
||||||
await getAgent().setInterestsPref({tags: selectedInterests})
|
await getAgent().setInterestsPref({tags: selectedInterests})
|
||||||
await saveFeeds(
|
await addSavedFeeds(
|
||||||
selectedFeeds.map(f => ({
|
selectedFeeds.map(f => ({
|
||||||
id: TID.nextStr(),
|
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
value: f,
|
value: f,
|
||||||
pinned: true,
|
pinned: true,
|
||||||
@@ -85,7 +83,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, addSavedFeeds, track])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
track('OnboardingV2:StepFinished:Start')
|
track('OnboardingV2:StepFinished:Start')
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {getAge} from '#/lib/strings/time'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {
|
import {
|
||||||
DEFAULT_PROD_FEED,
|
DEFAULT_PROD_FEED,
|
||||||
useAddSavedFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesSetBirthDateMutation,
|
usePreferencesSetBirthDateMutation,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useSessionApi} from '#/state/session'
|
import {useSessionApi} from '#/state/session'
|
||||||
@@ -208,7 +208,7 @@ export function useSubmitSignup({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {createAccount} = useSessionApi()
|
const {createAccount} = useSessionApi()
|
||||||
const {mutateAsync: setBirthDate} = usePreferencesSetBirthDateMutation()
|
const {mutateAsync: setBirthDate} = usePreferencesSetBirthDateMutation()
|
||||||
const {mutate: addSavedFeed} = useAddSavedFeedMutation()
|
const {mutate: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
const onboardingDispatch = useOnboardingDispatch()
|
const onboardingDispatch = useOnboardingDispatch()
|
||||||
|
|
||||||
return useCallback(
|
return useCallback(
|
||||||
@@ -266,7 +266,7 @@ export function useSubmitSignup({
|
|||||||
})
|
})
|
||||||
await setBirthDate({birthDate: state.dateOfBirth})
|
await setBirthDate({birthDate: state.dateOfBirth})
|
||||||
if (IS_PROD_SERVICE(state.serviceUrl)) {
|
if (IS_PROD_SERVICE(state.serviceUrl)) {
|
||||||
addSavedFeed(DEFAULT_PROD_FEED)
|
addSavedFeeds([DEFAULT_PROD_FEED])
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
onboardingDispatch({type: 'skip'}) // undo starting the onboard
|
onboardingDispatch({type: 'skip'}) // undo starting the onboard
|
||||||
@@ -314,7 +314,7 @@ export function useSubmitSignup({
|
|||||||
onboardingDispatch,
|
onboardingDispatch,
|
||||||
createAccount,
|
createAccount,
|
||||||
setBirthDate,
|
setBirthDate,
|
||||||
addSavedFeed,
|
addSavedFeeds,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,16 +232,16 @@ export function useSetSaveFeedsMutation() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAddSavedFeedMutation() {
|
export function useAddSavedFeedsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<
|
||||||
void,
|
void,
|
||||||
unknown,
|
unknown,
|
||||||
Pick<AppBskyActorDefs.SavedFeed, 'type' | 'value' | 'pinned'>
|
Pick<AppBskyActorDefs.SavedFeed, 'type' | 'value' | 'pinned'>[]
|
||||||
>({
|
>({
|
||||||
mutationFn: async savedFeed => {
|
mutationFn: async savedFeeds => {
|
||||||
await getAgent().addSavedFeedV2(savedFeed)
|
await getAgent().addSavedFeeds(savedFeeds)
|
||||||
track('CustomFeed:Save')
|
track('CustomFeed:Save')
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
@@ -255,8 +255,8 @@ export function useRemoveFeedMutation() {
|
|||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
return useMutation<void, unknown, Pick<AppBskyActorDefs.SavedFeed, 'id'>>({
|
return useMutation<void, unknown, Pick<AppBskyActorDefs.SavedFeed, 'id'>>({
|
||||||
mutationFn: async ({id}) => {
|
mutationFn: async savedFeed => {
|
||||||
await getAgent().removeSavedFeedV2(id)
|
await getAgent().removeSavedFeeds([savedFeed.id])
|
||||||
track('CustomFeed:Unsave')
|
track('CustomFeed:Unsave')
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {useLingui} from '@lingui/react'
|
|||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {FeedSourceInfo, useFeedSourceInfoQuery} from '#/state/queries/feed'
|
import {FeedSourceInfo, useFeedSourceInfoQuery} from '#/state/queries/feed'
|
||||||
import {
|
import {
|
||||||
useAddSavedFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
@@ -89,8 +89,8 @@ export function FeedSourceCardLoaded({
|
|||||||
const removePromptControl = Prompt.usePromptControl()
|
const removePromptControl = Prompt.usePromptControl()
|
||||||
const navigation = useNavigationDeduped()
|
const navigation = useNavigationDeduped()
|
||||||
|
|
||||||
const {isPending: isAddSavedFeedPending, mutateAsync: addSavedFeed} =
|
const {isPending: isAddSavedFeedPending, mutateAsync: addSavedFeeds} =
|
||||||
useAddSavedFeedMutation()
|
useAddSavedFeedsMutation()
|
||||||
const {isPending: isRemovePending, mutateAsync: removeFeed} =
|
const {isPending: isRemovePending, mutateAsync: removeFeed} =
|
||||||
useRemoveFeedMutation()
|
useRemoveFeedMutation()
|
||||||
|
|
||||||
@@ -103,17 +103,19 @@ export function FeedSourceCardLoaded({
|
|||||||
if (!feed) return
|
if (!feed) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await addSavedFeed({
|
await addSavedFeeds([
|
||||||
type: 'feed',
|
{
|
||||||
value: feed.uri,
|
type: 'feed',
|
||||||
pinned: pinOnSave,
|
value: feed.uri,
|
||||||
})
|
pinned: pinOnSave,
|
||||||
|
},
|
||||||
|
])
|
||||||
Toast.show(_(msg`Added to my feeds`))
|
Toast.show(_(msg`Added to my feeds`))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(_(msg`There was an issue contacting your server`))
|
Toast.show(_(msg`There was an issue contacting your server`))
|
||||||
logger.error('Failed to save feed', {message: e})
|
logger.error('Failed to save feed', {message: e})
|
||||||
}
|
}
|
||||||
}, [_, feed, pinOnSave, addSavedFeed])
|
}, [_, feed, pinOnSave, addSavedFeeds])
|
||||||
|
|
||||||
const onUnsave = React.useCallback(async () => {
|
const onUnsave = React.useCallback(async () => {
|
||||||
if (!savedFeedConfig) return
|
if (!savedFeedConfig) return
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {useLikeMutation, useUnlikeMutation} from '#/state/queries/like'
|
|||||||
import {FeedDescriptor} from '#/state/queries/post-feed'
|
import {FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed'
|
import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed'
|
||||||
import {
|
import {
|
||||||
useAddSavedFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
@@ -162,8 +162,8 @@ export function ProfileFeedScreenInner({
|
|||||||
const feedSectionRef = React.useRef<SectionRef>(null)
|
const feedSectionRef = React.useRef<SectionRef>(null)
|
||||||
const isScreenFocused = useIsFocused()
|
const isScreenFocused = useIsFocused()
|
||||||
|
|
||||||
const {mutateAsync: addSavedFeed, isPending: isAddSavedFeedPending} =
|
const {mutateAsync: addSavedFeeds, isPending: isAddSavedFeedPending} =
|
||||||
useAddSavedFeedMutation()
|
useAddSavedFeedsMutation()
|
||||||
const {mutateAsync: removeFeed, isPending: isRemovePending} =
|
const {mutateAsync: removeFeed, isPending: isRemovePending} =
|
||||||
useRemoveFeedMutation()
|
useRemoveFeedMutation()
|
||||||
const {mutateAsync: updateFeed, isPending: isUpdateFeedPending} =
|
const {mutateAsync: updateFeed, isPending: isUpdateFeedPending} =
|
||||||
@@ -193,11 +193,13 @@ export function ProfileFeedScreenInner({
|
|||||||
Toast.show(_(msg`Removed from your feeds`))
|
Toast.show(_(msg`Removed from your feeds`))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await addSavedFeed({
|
await addSavedFeeds([
|
||||||
type: 'feed',
|
{
|
||||||
value: feedInfo.uri,
|
type: 'feed',
|
||||||
pinned: false,
|
value: feedInfo.uri,
|
||||||
})
|
pinned: false,
|
||||||
|
},
|
||||||
|
])
|
||||||
Toast.show(_(msg`Saved to your feeds`))
|
Toast.show(_(msg`Saved to your feeds`))
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -208,7 +210,7 @@ export function ProfileFeedScreenInner({
|
|||||||
)
|
)
|
||||||
logger.error('Failed up update feeds', {message: err})
|
logger.error('Failed up update feeds', {message: err})
|
||||||
}
|
}
|
||||||
}, [_, playHaptic, feedInfo, removeFeed, addSavedFeed, savedFeedConfig])
|
}, [_, playHaptic, feedInfo, removeFeed, addSavedFeeds, savedFeedConfig])
|
||||||
|
|
||||||
const onTogglePinned = React.useCallback(async () => {
|
const onTogglePinned = React.useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -227,17 +229,19 @@ export function ProfileFeedScreenInner({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await addSavedFeed({
|
await addSavedFeeds([
|
||||||
type: 'feed',
|
{
|
||||||
value: feedInfo.uri,
|
type: 'feed',
|
||||||
pinned: true,
|
value: feedInfo.uri,
|
||||||
})
|
pinned: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(_(msg`There was an issue contacting the server`))
|
Toast.show(_(msg`There was an issue contacting the server`))
|
||||||
logger.error('Failed to toggle pinned feed', {message: e})
|
logger.error('Failed to toggle pinned feed', {message: e})
|
||||||
}
|
}
|
||||||
}, [playHaptic, feedInfo, _, savedFeedConfig, updateFeed, addSavedFeed])
|
}, [playHaptic, feedInfo, _, savedFeedConfig, updateFeed, addSavedFeeds])
|
||||||
|
|
||||||
const onPressShare = React.useCallback(() => {
|
const onPressShare = React.useCallback(() => {
|
||||||
const url = toShareUrl(feedInfo.route.href)
|
const url = toShareUrl(feedInfo.route.href)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
import {FeedDescriptor} from '#/state/queries/post-feed'
|
import {FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed'
|
import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed'
|
||||||
import {
|
import {
|
||||||
useAddSavedFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
@@ -251,8 +251,8 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
|||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
|
|
||||||
const {mutateAsync: addSavedFeed, isPending: isAddSavedFeedPending} =
|
const {mutateAsync: addSavedFeeds, isPending: isAddSavedFeedPending} =
|
||||||
useAddSavedFeedMutation()
|
useAddSavedFeedsMutation()
|
||||||
const {mutateAsync: removeSavedFeed, isPending: isRemovePending} =
|
const {mutateAsync: removeSavedFeed, isPending: isRemovePending} =
|
||||||
useRemoveFeedMutation()
|
useRemoveFeedMutation()
|
||||||
|
|
||||||
@@ -276,18 +276,20 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
|||||||
await removeSavedFeed(savedFeedConfig)
|
await removeSavedFeed(savedFeedConfig)
|
||||||
Toast.show(_(msg`Removed from your feeds`))
|
Toast.show(_(msg`Removed from your feeds`))
|
||||||
} else {
|
} else {
|
||||||
await addSavedFeed({
|
await addSavedFeeds([
|
||||||
type: 'list',
|
{
|
||||||
value: list.uri,
|
type: 'list',
|
||||||
pinned: true,
|
value: list.uri,
|
||||||
})
|
pinned: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
Toast.show(_(msg`Saved to your feeds`))
|
Toast.show(_(msg`Saved to your feeds`))
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(_(msg`There was an issue contacting the server`))
|
Toast.show(_(msg`There was an issue contacting the server`))
|
||||||
logger.error('Failed to toggle pinned feed', {message: e})
|
logger.error('Failed to toggle pinned feed', {message: e})
|
||||||
}
|
}
|
||||||
}, [playHaptic, addSavedFeed, removeSavedFeed, list.uri, _, savedFeedConfig])
|
}, [playHaptic, addSavedFeeds, removeSavedFeed, list.uri, _, savedFeedConfig])
|
||||||
|
|
||||||
const onSubscribeMute = useCallback(async () => {
|
const onSubscribeMute = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user