Movable following feed (#3593)
* Handle home algo with backwards compat * Remove todo, fix pwi view * Simplify filter logic * Handle edge case * Handle home algo in FeedSourceCard * Fix handling of pinned feed if home algo is disabled * Handle home algo on ProfileFeed screen * Rename * Fix pinned feeds key * Improve perf of pinned feeds with primary algo * Update statsig API * Revert unneeded changes * Support following feed as well * Better formatting * Clarify primary algo usage * Better comment * Handle saved feed screen edge case * Restore Feeds sparkle, fix line height * Move gate call down * Filter out primary algo from feeds page * Filter dupe from Feeds screen * Simplify logic * Missing following handling * Hide primary feed setting outside exp * Revert testing change * Migrate usePinnedFeedInfos * Migrate FeedSourceCard * Migrate Feeds screen * Migrate SavedFeeds screen * Handle timeline in feed infos * Finish migrating ProfileFeed, FeedSourceCard * Migrate ProfileList * Finalize mutation hooks * Allow unsaving lists * Handle following feed on Feeds screen * Handle following on SavedFeeds * Get rid of deprecated interface usages * Handle no pinned feeds * Handle no feeds on Feeds screen * Reuse component on SavedFeeds screen * Handle no following feed * Remove primary algo references * Migrate to new plural APIs * Remove unused event * Prevent duplicate keys * Make handling much more clear * Dedupe useHeaderOffset * Filter unknown feed types at source * Use just following * Immprove key handling * Resume from last tab * Bump sdk * Revert Gemfile * Additional protection in FeedSourceCard * Fix ProfileList save/unsave handling * Translate * Translate * Match existing handling post-signup * Ensure onboarding results in correct selected feeds * Some testing tweaks on create/onboarding * Revert primary algo consderations * Remove comment * Handle default feed setting * Rm unnecessary type cast * Remove premature gate check * Remove nullable check in onPageSelecting, assume the pager checks bounds * Use null for default selected feed * Rm unrelated change * Remove the concept of __key__ I don't think this concept is consistent. It's introduced on FeedSourceInfo which is used both by pinned feeds and by useFeedSourceInfoQuery. Pinned feeds use the pinning ID there. But there is no pinning ID for useFeedSourceInfoQuery. So this means this field is sometimes one thing and sometimes some other thing. That is a decent sign that it shouldn't be on that type at all. It's not used anywhere except the desktop feed enumeration. It seems reasonable to assume there that we wouldn't want to show the same feed URL twice. (And if it does occur in the array twice, IMO we should solve that at the API level and dedupe it on read or next write.) So I think we should just use the URL in that place. (I used the descriptor, which is equivalent.) * Dedupe pinned feeds by URL on read * Filter timeline out of mergefeed sources * Put FeedDescriptor into FeedSourceInfo * Group saved info with feed for pins This removes a loop within a loop within a loop. * Fix Feeds link on native --------- Co-authored-by: Dan Abramov <dan.abramov@gmail.com>zio/stable
parent
2974ce1b20
commit
08979f37e7
|
@ -1,5 +1,5 @@
|
||||||
import {requireNativeViewManager} from 'expo-modules-core'
|
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
import {requireNativeViewManager} from 'expo-modules-core'
|
||||||
|
|
||||||
import {ExpoScrollForwarderViewProps} from './ExpoScrollForwarder.types'
|
import {ExpoScrollForwarderViewProps} from './ExpoScrollForwarder.types'
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto-labs/api": "^0.12.8-clipclops.0",
|
"@atproto-labs/api": "^0.12.8-clipclops.0",
|
||||||
"@atproto/api": "^0.12.5",
|
"@atproto/api": "^0.12.6",
|
||||||
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
"@bam.tech/react-native-image-resizer": "^3.0.4",
|
||||||
"@braintree/sanitize-url": "^6.0.2",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
"@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {AppBskyLabelerDefs} from '@atproto/api'
|
||||||
import {msg, Plural, Trans} from '@lingui/macro'
|
import {msg, Plural, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {AppBskyLabelerDefs} from '@atproto/api'
|
|
||||||
|
|
||||||
import {getLabelingServiceTitle} from '#/lib/moderation'
|
import {getLabelingServiceTitle} from '#/lib/moderation'
|
||||||
import {Link as InternalLink, LinkProps} from '#/components/Link'
|
|
||||||
import {Text} from '#/components/Typography'
|
|
||||||
import {useLabelerInfoQuery} from '#/state/queries/labeler'
|
|
||||||
import {atoms as a, useTheme, ViewStyleProp} from '#/alf'
|
|
||||||
import {RichText} from '#/components/RichText'
|
|
||||||
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '../icons/Chevron'
|
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
import {useLabelerInfoQuery} from '#/state/queries/labeler'
|
||||||
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
|
import {atoms as a, useTheme, ViewStyleProp} from '#/alf'
|
||||||
|
import {Link as InternalLink, LinkProps} from '#/components/Link'
|
||||||
|
import {RichText} from '#/components/RichText'
|
||||||
|
import {Text} from '#/components/Typography'
|
||||||
|
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '../icons/Chevron'
|
||||||
|
|
||||||
type LabelingServiceProps = {
|
type LabelingServiceProps = {
|
||||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
labeler: AppBskyLabelerDefs.LabelerViewDetailed
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
import {useWindowDimensions} from 'react-native'
|
||||||
|
|
||||||
|
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
||||||
|
|
||||||
|
export function useHeaderOffset() {
|
||||||
|
const {isDesktop, isTablet} = useWebMediaQueries()
|
||||||
|
const {fontScale} = useWindowDimensions()
|
||||||
|
if (isDesktop || isTablet) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
const navBarHeight = 42
|
||||||
|
const tabBarPad = 10 + 10 + 3 // padding + border
|
||||||
|
const normalLineHeight = 1.2
|
||||||
|
const tabBarText = 16 * normalLineHeight * fontScale
|
||||||
|
return navBarHeight + tabBarPad + tabBarText
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
import {createSinglePathSVG} from './TEMPLATE'
|
||||||
|
|
||||||
|
export const Home_Stroke2_Corner0_Rounded = createSinglePathSVG({
|
||||||
|
path: 'M11.46 1.362a2 2 0 0 1 1.08 0c.249.07.448.188.611.301.146.102.306.232.467.363l6.421 5.218.046.036c.169.137.38.308.54.53a2 2 0 0 1 .304.64c.073.264.072.536.071.753v9.229c0 .252 0 .498-.017.706a2.023 2.023 0 0 1-.201.77 2 2 0 0 1-.874.874 2.02 2.02 0 0 1-.77.201c-.208.017-.454.017-.706.017H5.568c-.252 0-.498 0-.706-.017a2.02 2.02 0 0 1-.77-.201 2 2 0 0 1-.874-.874 2.022 2.022 0 0 1-.201-.77C3 18.93 3 18.684 3 18.432V9.203c0-.217-.002-.49.07-.754a2 2 0 0 1 .304-.638c.16-.223.372-.394.541-.53l.045-.037 6.422-5.218c.161-.13.321-.26.467-.362.163-.114.362-.232.612-.302Zm.532 1.943c-.077.054-.18.136-.37.29l-6.4 5.2a6.315 6.315 0 0 0-.215.18c-.002 0-.003.002-.004.003v.004C5 9.036 5 9.112 5 9.262V18.4a8.18 8.18 0 0 0 .011.588l.014.002c.116.01.278.01.575.01H8v-5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v5h2.4a8.207 8.207 0 0 0 .589-.012v-.013c.01-.116.011-.279.011-.575V9.262c0-.15 0-.226-.003-.28v-.004l-.003-.003a6.448 6.448 0 0 0-.216-.18l-6.4-5.2a7.373 7.373 0 0 0-.37-.29L12 3.299l-.008.006ZM14 19v-5h-4v5h4Z',
|
||||||
|
})
|
||||||
|
|
||||||
|
export const Home_Filled_Corner0_Rounded = createSinglePathSVG({
|
||||||
|
path: 'M13.261 1.736a2 2 0 0 0-2.522 0l-7 5.687A2 2 0 0 0 3 8.976V19a2 2 0 0 0 2 2h3v-8a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v8h3a2 2 0 0 0 2-2V8.976a2 2 0 0 0-.739-1.553l-7-5.687ZM14 21h-4v-7h4v7Z',
|
||||||
|
})
|
|
@ -3,10 +3,10 @@ import {StyleProp, View, ViewStyle} from 'react-native'
|
||||||
import {AppBskyFeedDefs, ComAtprotoLabelDefs} from '@atproto/api'
|
import {AppBskyFeedDefs, ComAtprotoLabelDefs} from '@atproto/api'
|
||||||
import {msg, Plural} from '@lingui/macro'
|
import {msg, Plural} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useSession} from '#/state/session'
|
|
||||||
|
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
import {Button, ButtonText, ButtonIcon, ButtonSize} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonSize, ButtonText} from '#/components/Button'
|
||||||
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
|
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
|
||||||
import {
|
import {
|
||||||
LabelsOnMeDialog,
|
LabelsOnMeDialog,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {Insets, Platform} from 'react-native'
|
import {Insets, Platform} from 'react-native'
|
||||||
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
|
|
||||||
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'
|
||||||
|
@ -44,7 +45,7 @@ export function IS_TEST_USER(handle?: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IS_PROD_SERVICE(url?: string) {
|
export function IS_PROD_SERVICE(url?: string) {
|
||||||
return url && url !== STAGING_SERVICE && url !== LOCAL_DEV_SERVICE
|
return url && url !== STAGING_SERVICE && !url.startsWith(LOCAL_DEV_SERVICE)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PROD_DEFAULT_FEED = (rkey: string) =>
|
export const PROD_DEFAULT_FEED = (rkey: string) =>
|
||||||
|
@ -92,6 +93,24 @@ export const BSKY_FEED_OWNER_DIDS = [
|
||||||
'did:plc:q6gjnaw2blty4crticxkmujt',
|
'did:plc:q6gjnaw2blty4crticxkmujt',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const DISCOVER_FEED_URI =
|
||||||
|
'at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot'
|
||||||
|
export const DISCOVER_SAVED_FEED = {
|
||||||
|
type: 'feed',
|
||||||
|
value: DISCOVER_FEED_URI,
|
||||||
|
pinned: true,
|
||||||
|
}
|
||||||
|
export const TIMELINE_SAVED_FEED = {
|
||||||
|
type: 'timeline',
|
||||||
|
value: 'following',
|
||||||
|
pinned: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const RECOMMENDED_SAVED_FEEDS: Pick<
|
||||||
|
AppBskyActorDefs.SavedFeed,
|
||||||
|
'type' | 'value' | 'pinned'
|
||||||
|
>[] = [DISCOVER_SAVED_FEED, TIMELINE_SAVED_FEED]
|
||||||
|
|
||||||
export const GIF_SERVICE = 'https://gifs.bsky.app'
|
export const GIF_SERVICE = 'https://gifs.bsky.app'
|
||||||
|
|
||||||
export const GIF_SEARCH = (params: string) =>
|
export const GIF_SEARCH = (params: string) =>
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import React from 'react'
|
||||||
|
import {View} from 'react-native'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {TIMELINE_SAVED_FEED} from '#/lib/constants'
|
||||||
|
import {useAddSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
import {InlineLinkText} from '#/components/Link'
|
||||||
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
|
export function NoFollowingFeed() {
|
||||||
|
const t = useTheme()
|
||||||
|
const {_} = useLingui()
|
||||||
|
const {mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()
|
||||||
|
|
||||||
|
const addRecommendedFeeds = React.useCallback(
|
||||||
|
(e: any) => {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
addSavedFeeds([
|
||||||
|
{
|
||||||
|
...TIMELINE_SAVED_FEED,
|
||||||
|
pinned: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
// prevent navigation
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
[addSavedFeeds],
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[a.flex_row, a.flex_wrap, a.align_center, a.py_md, a.px_lg]}>
|
||||||
|
<Text
|
||||||
|
style={[a.leading_snug, t.atoms.text_contrast_medium, {maxWidth: 310}]}>
|
||||||
|
<Trans>Looks like you're missing a following feed.</Trans>{' '}
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<InlineLinkText
|
||||||
|
to="/"
|
||||||
|
label={_(msg`Add the default feed of only people you follow`)}
|
||||||
|
onPress={addRecommendedFeeds}
|
||||||
|
style={[a.leading_snug]}>
|
||||||
|
<Trans>Click here to add one.</Trans>
|
||||||
|
</InlineLinkText>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
import React from 'react'
|
||||||
|
import {View} from 'react-native'
|
||||||
|
import {TID} from '@atproto/common-web'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants'
|
||||||
|
import {useOverwriteSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
|
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
||||||
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Explicitly named, since the CTA in this component will overwrite all saved
|
||||||
|
* feeds if pressed. It should only be presented to the user if they actually
|
||||||
|
* have no other feeds saved.
|
||||||
|
*/
|
||||||
|
export function NoSavedFeedsOfAnyType() {
|
||||||
|
const t = useTheme()
|
||||||
|
const {_} = useLingui()
|
||||||
|
const {isPending, mutateAsync: overwriteSavedFeeds} =
|
||||||
|
useOverwriteSavedFeedsMutation()
|
||||||
|
|
||||||
|
const addRecommendedFeeds = React.useCallback(async () => {
|
||||||
|
await overwriteSavedFeeds(
|
||||||
|
RECOMMENDED_SAVED_FEEDS.map(f => ({
|
||||||
|
...f,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
}, [overwriteSavedFeeds])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[a.flex_row, a.flex_wrap, a.justify_between, a.p_xl, a.gap_md]}>
|
||||||
|
<Text
|
||||||
|
style={[a.leading_snug, t.atoms.text_contrast_medium, {maxWidth: 310}]}>
|
||||||
|
<Trans>
|
||||||
|
Looks like you haven't saved any feeds! Use our recommendations or
|
||||||
|
browse more below.
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
disabled={isPending}
|
||||||
|
label={_(msg`Apply default recommended feeds`)}
|
||||||
|
size="small"
|
||||||
|
variant="solid"
|
||||||
|
color="primary"
|
||||||
|
onPress={addRecommendedFeeds}>
|
||||||
|
<ButtonIcon icon={Plus} position="left" />
|
||||||
|
<ButtonText>{_(msg`Use recommended`)}</ButtonText>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
import React from 'react'
|
||||||
|
import {View} from 'react-native'
|
||||||
|
import {TID} from '@atproto/common-web'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
|
import {DISCOVER_SAVED_FEED, TIMELINE_SAVED_FEED} from '#/lib/constants'
|
||||||
|
import {isNative} from '#/platform/detection'
|
||||||
|
import {useOverwriteSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
|
import {UsePreferencesQueryResponse} from '#/state/queries/preferences'
|
||||||
|
import {NavigationProp} from 'lib/routes/types'
|
||||||
|
import {CenteredView} from '#/view/com/util/Views'
|
||||||
|
import {atoms as a} from '#/alf'
|
||||||
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
|
import {useHeaderOffset} from '#/components/hooks/useHeaderOffset'
|
||||||
|
import {ListSparkle_Stroke2_Corner0_Rounded as ListSparkle} from '#/components/icons/ListSparkle'
|
||||||
|
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
||||||
|
import {Link} from '#/components/Link'
|
||||||
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
|
export function NoFeedsPinned({
|
||||||
|
preferences,
|
||||||
|
}: {
|
||||||
|
preferences: UsePreferencesQueryResponse
|
||||||
|
}) {
|
||||||
|
const {_} = useLingui()
|
||||||
|
const headerOffset = useHeaderOffset()
|
||||||
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
const {isPending, mutateAsync: overwriteSavedFeeds} =
|
||||||
|
useOverwriteSavedFeedsMutation()
|
||||||
|
|
||||||
|
const addRecommendedFeeds = React.useCallback(async () => {
|
||||||
|
let skippedTimeline = false
|
||||||
|
let skippedDiscover = false
|
||||||
|
let remainingSavedFeeds = []
|
||||||
|
|
||||||
|
// remove first instance of both timeline and discover, since we're going to overwrite them
|
||||||
|
for (const savedFeed of preferences.savedFeeds) {
|
||||||
|
if (savedFeed.type === 'timeline' && !skippedTimeline) {
|
||||||
|
skippedTimeline = true
|
||||||
|
} else if (
|
||||||
|
savedFeed.value === DISCOVER_SAVED_FEED.value &&
|
||||||
|
!skippedDiscover
|
||||||
|
) {
|
||||||
|
skippedDiscover = true
|
||||||
|
} else {
|
||||||
|
remainingSavedFeeds.push(savedFeed)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const toSave = [
|
||||||
|
{
|
||||||
|
...DISCOVER_SAVED_FEED,
|
||||||
|
pinned: true,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...TIMELINE_SAVED_FEED,
|
||||||
|
pinned: true,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
},
|
||||||
|
...remainingSavedFeeds,
|
||||||
|
]
|
||||||
|
|
||||||
|
await overwriteSavedFeeds(toSave)
|
||||||
|
}, [overwriteSavedFeeds, preferences.savedFeeds])
|
||||||
|
|
||||||
|
const onPressFeedsLink = React.useCallback(() => {
|
||||||
|
if (isNative) {
|
||||||
|
// Hack that's necessary due to how our navigators are set up.
|
||||||
|
navigation.navigate('FeedsTab')
|
||||||
|
navigation.popToTop()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}, [navigation])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<CenteredView sideBorders style={[a.h_full_vh]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.align_center,
|
||||||
|
a.h_full_vh,
|
||||||
|
a.py_3xl,
|
||||||
|
a.px_xl,
|
||||||
|
{
|
||||||
|
paddingTop: headerOffset + a.py_3xl.paddingTop,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<View style={[a.align_center, a.gap_sm, a.pb_xl]}>
|
||||||
|
<Text style={[a.text_xl, a.font_bold]}>
|
||||||
|
<Trans>Whoops!</Trans>
|
||||||
|
</Text>
|
||||||
|
<Text
|
||||||
|
style={[a.text_md, a.text_center, a.leading_snug, {maxWidth: 340}]}>
|
||||||
|
<Trans>
|
||||||
|
Looks like you unpinned all your feeds. But don't worry, you can
|
||||||
|
add some below 😄
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={[a.flex_row, a.gap_md, a.justify_center, a.flex_wrap]}>
|
||||||
|
<Button
|
||||||
|
disabled={isPending}
|
||||||
|
label={_(msg`Apply default recommended feeds`)}
|
||||||
|
size="medium"
|
||||||
|
variant="solid"
|
||||||
|
color="primary"
|
||||||
|
onPress={addRecommendedFeeds}>
|
||||||
|
<ButtonIcon icon={Plus} position="left" />
|
||||||
|
<ButtonText>{_(msg`Add recommended feeds`)}</ButtonText>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Link
|
||||||
|
label={_(msg`Browse other feeds`)}
|
||||||
|
to="/feeds"
|
||||||
|
onPress={onPressFeedsLink}
|
||||||
|
size="medium"
|
||||||
|
variant="solid"
|
||||||
|
color="secondary">
|
||||||
|
<ButtonIcon icon={ListSparkle} position="left" />
|
||||||
|
<ButtonText>{_(msg`Browse other feeds`)}</ButtonText>
|
||||||
|
</Link>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</CenteredView>
|
||||||
|
)
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {LinearGradient} from 'expo-linear-gradient'
|
import {LinearGradient} from 'expo-linear-gradient'
|
||||||
import {Trans, msg} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {FeedSourceInfo, useFeedSourceInfoQuery} from '#/state/queries/feed'
|
import {FeedSourceInfo, useFeedSourceInfoQuery} from '#/state/queries/feed'
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
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'
|
||||||
|
|
||||||
import {useAnalytics} from '#/lib/analytics/analytics'
|
import {useAnalytics} from '#/lib/analytics/analytics'
|
||||||
import {BSKY_APP_ACCOUNT_DID} from '#/lib/constants'
|
import {BSKY_APP_ACCOUNT_DID, IS_PROD_SERVICE} from '#/lib/constants'
|
||||||
|
import {DISCOVER_SAVED_FEED, TIMELINE_SAVED_FEED} 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 {useOverwriteSavedFeedsMutation} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {useOnboardingDispatch} from '#/state/shell'
|
import {useOnboardingDispatch} from '#/state/shell'
|
||||||
import {
|
import {
|
||||||
|
@ -37,7 +39,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: overwriteSavedFeeds} = useOverwriteSavedFeedsMutation()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const finishOnboarding = React.useCallback(async () => {
|
const finishOnboarding = React.useCallback(async () => {
|
||||||
|
@ -64,10 +66,41 @@ 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({
|
|
||||||
saved: selectedFeeds,
|
// TODO: In the reduced onboarding, we'll want to exit early here.
|
||||||
pinned: selectedFeeds,
|
|
||||||
})
|
const otherFeeds = selectedFeeds.length
|
||||||
|
? selectedFeeds.map(f => ({
|
||||||
|
type: 'feed',
|
||||||
|
value: f,
|
||||||
|
pinned: true,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If no selected feeds and we're in prod, add the discover feed
|
||||||
|
* (mimics old behavior)
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
IS_PROD_SERVICE(getAgent().service.toString()) &&
|
||||||
|
!otherFeeds.length
|
||||||
|
) {
|
||||||
|
otherFeeds.push({
|
||||||
|
...DISCOVER_SAVED_FEED,
|
||||||
|
pinned: true,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
await overwriteSavedFeeds([
|
||||||
|
{
|
||||||
|
...TIMELINE_SAVED_FEED,
|
||||||
|
pinned: true,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
},
|
||||||
|
...otherFeeds,
|
||||||
|
])
|
||||||
})(),
|
})(),
|
||||||
])
|
])
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
@ -82,7 +115,15 @@ 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, getAgent])
|
}, [
|
||||||
|
state,
|
||||||
|
dispatch,
|
||||||
|
onboardDispatch,
|
||||||
|
setSaving,
|
||||||
|
overwriteSavedFeeds,
|
||||||
|
track,
|
||||||
|
getAgent,
|
||||||
|
])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
track('OnboardingV2:StepFinished:Start')
|
track('OnboardingV2:StepFinished:Start')
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
|
|
||||||
import {FeedTuner} from '#/lib/api/feed-manip'
|
import {FeedTuner} from '#/lib/api/feed-manip'
|
||||||
import {FeedDescriptor} from '../queries/post-feed'
|
import {FeedDescriptor} from '../queries/post-feed'
|
||||||
import {useLanguagePrefs} from './languages'
|
|
||||||
import {usePreferencesQuery} from '../queries/preferences'
|
import {usePreferencesQuery} from '../queries/preferences'
|
||||||
import {useSession} from '../session'
|
import {useSession} from '../session'
|
||||||
|
import {useLanguagePrefs} from './languages'
|
||||||
|
|
||||||
export function useFeedTuners(feedDesc: FeedDescriptor) {
|
export function useFeedTuners(feedDesc: FeedDescriptor) {
|
||||||
const langPrefs = useLanguagePrefs()
|
const langPrefs = useLanguagePrefs()
|
||||||
|
@ -20,7 +21,7 @@ export function useFeedTuners(feedDesc: FeedDescriptor) {
|
||||||
if (feedDesc.startsWith('list')) {
|
if (feedDesc.startsWith('list')) {
|
||||||
return [FeedTuner.dedupReposts]
|
return [FeedTuner.dedupReposts]
|
||||||
}
|
}
|
||||||
if (feedDesc === 'home' || feedDesc === 'following') {
|
if (feedDesc === 'following') {
|
||||||
const feedTuners = []
|
const feedTuners = []
|
||||||
|
|
||||||
if (preferences?.feedViewPrefs.hideReposts) {
|
if (preferences?.feedViewPrefs.hideReposts) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
AppBskyActorDefs,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyGraphDefs,
|
AppBskyGraphDefs,
|
||||||
AppBskyUnspeccedGetPopularFeedGenerators,
|
AppBskyUnspeccedGetPopularFeedGenerators,
|
||||||
|
@ -13,16 +14,19 @@ import {
|
||||||
useQuery,
|
useQuery,
|
||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
import {DISCOVER_FEED_URI, DISCOVER_SAVED_FEED} from '#/lib/constants'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
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 {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {router} from '#/routes'
|
import {router} from '#/routes'
|
||||||
|
import {FeedDescriptor} from './post-feed'
|
||||||
|
|
||||||
export type FeedSourceFeedInfo = {
|
export type FeedSourceFeedInfo = {
|
||||||
type: 'feed'
|
type: 'feed'
|
||||||
uri: string
|
uri: string
|
||||||
|
feedDescriptor: FeedDescriptor
|
||||||
route: {
|
route: {
|
||||||
href: string
|
href: string
|
||||||
name: string
|
name: string
|
||||||
|
@ -41,6 +45,7 @@ export type FeedSourceFeedInfo = {
|
||||||
export type FeedSourceListInfo = {
|
export type FeedSourceListInfo = {
|
||||||
type: 'list'
|
type: 'list'
|
||||||
uri: string
|
uri: string
|
||||||
|
feedDescriptor: FeedDescriptor
|
||||||
route: {
|
route: {
|
||||||
href: string
|
href: string
|
||||||
name: string
|
name: string
|
||||||
|
@ -79,6 +84,7 @@ export function hydrateFeedGenerator(
|
||||||
return {
|
return {
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
uri: view.uri,
|
uri: view.uri,
|
||||||
|
feedDescriptor: `feedgen|${view.uri}`,
|
||||||
cid: view.cid,
|
cid: view.cid,
|
||||||
route: {
|
route: {
|
||||||
href,
|
href,
|
||||||
|
@ -110,6 +116,7 @@ export function hydrateList(view: AppBskyGraphDefs.ListView): FeedSourceInfo {
|
||||||
return {
|
return {
|
||||||
type: 'list',
|
type: 'list',
|
||||||
uri: view.uri,
|
uri: view.uri,
|
||||||
|
feedDescriptor: `list|${view.uri}`,
|
||||||
route: {
|
route: {
|
||||||
href,
|
href,
|
||||||
name: route[0],
|
name: route[0],
|
||||||
|
@ -202,27 +209,15 @@ export function useSearchPopularFeedsMutation() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const FOLLOWING_FEED_STUB: FeedSourceInfo = {
|
export type SavedFeedSourceInfo = FeedSourceInfo & {
|
||||||
type: 'feed',
|
savedFeed: AppBskyActorDefs.SavedFeed
|
||||||
displayName: 'Following',
|
|
||||||
uri: '',
|
|
||||||
route: {
|
|
||||||
href: '/',
|
|
||||||
name: 'Home',
|
|
||||||
params: {},
|
|
||||||
},
|
|
||||||
cid: '',
|
|
||||||
avatar: '',
|
|
||||||
description: new RichText({text: ''}),
|
|
||||||
creatorDid: '',
|
|
||||||
creatorHandle: '',
|
|
||||||
likeCount: 0,
|
|
||||||
likeUri: '',
|
|
||||||
}
|
}
|
||||||
const DISCOVER_FEED_STUB: FeedSourceInfo = {
|
|
||||||
|
const PWI_DISCOVER_FEED_STUB: SavedFeedSourceInfo = {
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
displayName: 'Discover',
|
displayName: 'Discover',
|
||||||
uri: '',
|
uri: DISCOVER_FEED_URI,
|
||||||
|
feedDescriptor: `feedgen|${DISCOVER_FEED_URI}`,
|
||||||
route: {
|
route: {
|
||||||
href: '/',
|
href: '/',
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
|
@ -235,6 +230,11 @@ const DISCOVER_FEED_STUB: FeedSourceInfo = {
|
||||||
creatorHandle: '',
|
creatorHandle: '',
|
||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
likeUri: '',
|
likeUri: '',
|
||||||
|
// ---
|
||||||
|
savedFeed: {
|
||||||
|
id: 'pwi-discover',
|
||||||
|
...DISCOVER_SAVED_FEED,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
|
const pinnedFeedInfosQueryKeyRoot = 'pinnedFeedsInfos'
|
||||||
|
@ -243,43 +243,45 @@ export function usePinnedFeedsInfos() {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
|
const {data: preferences, isLoading: isLoadingPrefs} = usePreferencesQuery()
|
||||||
const pinnedUris = preferences?.feeds?.pinned ?? []
|
const pinnedItems = preferences?.savedFeeds.filter(feed => feed.pinned) ?? []
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
staleTime: STALE.INFINITY,
|
staleTime: STALE.INFINITY,
|
||||||
enabled: !isLoadingPrefs,
|
enabled: !isLoadingPrefs,
|
||||||
queryKey: [
|
queryKey: [
|
||||||
pinnedFeedInfosQueryKeyRoot,
|
pinnedFeedInfosQueryKeyRoot,
|
||||||
(hasSession ? 'authed:' : 'unauthed:') + pinnedUris.join(','),
|
(hasSession ? 'authed:' : 'unauthed:') +
|
||||||
|
pinnedItems.map(f => f.value).join(','),
|
||||||
],
|
],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
let resolved = new Map()
|
if (!hasSession) {
|
||||||
|
return [PWI_DISCOVER_FEED_STUB]
|
||||||
|
}
|
||||||
|
|
||||||
|
let resolved = new Map<string, FeedSourceInfo>()
|
||||||
|
|
||||||
// Get all feeds. We can do this in a batch.
|
// Get all feeds. We can do this in a batch.
|
||||||
const feedUris = pinnedUris.filter(
|
const pinnedFeeds = pinnedItems.filter(feed => feed.type === 'feed')
|
||||||
uri => getFeedTypeFromUri(uri) === 'feed',
|
|
||||||
)
|
|
||||||
let feedsPromise = Promise.resolve()
|
let feedsPromise = Promise.resolve()
|
||||||
if (feedUris.length > 0) {
|
if (pinnedFeeds.length > 0) {
|
||||||
feedsPromise = getAgent()
|
feedsPromise = getAgent()
|
||||||
.app.bsky.feed.getFeedGenerators({
|
.app.bsky.feed.getFeedGenerators({
|
||||||
feeds: feedUris,
|
feeds: pinnedFeeds.map(f => f.value),
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
for (let feedView of res.data.feeds) {
|
for (let i = 0; i < res.data.feeds.length; i++) {
|
||||||
|
const feedView = res.data.feeds[i]
|
||||||
resolved.set(feedView.uri, hydrateFeedGenerator(feedView))
|
resolved.set(feedView.uri, hydrateFeedGenerator(feedView))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all lists. This currently has to be done individually.
|
// Get all lists. This currently has to be done individually.
|
||||||
const listUris = pinnedUris.filter(
|
const pinnedLists = pinnedItems.filter(feed => feed.type === 'list')
|
||||||
uri => getFeedTypeFromUri(uri) === 'list',
|
const listsPromises = pinnedLists.map(list =>
|
||||||
)
|
|
||||||
const listsPromises = listUris.map(listUri =>
|
|
||||||
getAgent()
|
getAgent()
|
||||||
.app.bsky.graph.getList({
|
.app.bsky.graph.getList({
|
||||||
list: listUri,
|
list: list.value,
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -288,12 +290,37 @@ export function usePinnedFeedsInfos() {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
// The returned result will have the original order.
|
|
||||||
const result = [hasSession ? FOLLOWING_FEED_STUB : DISCOVER_FEED_STUB]
|
|
||||||
await Promise.allSettled([feedsPromise, ...listsPromises])
|
await Promise.allSettled([feedsPromise, ...listsPromises])
|
||||||
for (let pinnedUri of pinnedUris) {
|
|
||||||
if (resolved.has(pinnedUri)) {
|
// order the feeds/lists in the order they were pinned
|
||||||
result.push(resolved.get(pinnedUri))
|
const result: SavedFeedSourceInfo[] = []
|
||||||
|
for (let pinnedItem of pinnedItems) {
|
||||||
|
const feedInfo = resolved.get(pinnedItem.value)
|
||||||
|
if (feedInfo) {
|
||||||
|
result.push({
|
||||||
|
...feedInfo,
|
||||||
|
savedFeed: pinnedItem,
|
||||||
|
})
|
||||||
|
} else if (pinnedItem.type === 'timeline') {
|
||||||
|
result.push({
|
||||||
|
type: 'feed',
|
||||||
|
displayName: 'Following',
|
||||||
|
uri: pinnedItem.value,
|
||||||
|
feedDescriptor: 'following',
|
||||||
|
route: {
|
||||||
|
href: '/',
|
||||||
|
name: 'Home',
|
||||||
|
params: {},
|
||||||
|
},
|
||||||
|
cid: '',
|
||||||
|
avatar: '',
|
||||||
|
description: new RichText({text: ''}),
|
||||||
|
creatorDid: '',
|
||||||
|
creatorHandle: '',
|
||||||
|
likeCount: 0,
|
||||||
|
likeUri: '',
|
||||||
|
savedFeed: pinnedItem,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -44,8 +44,8 @@ type AuthorFilter =
|
||||||
| 'posts_with_media'
|
| 'posts_with_media'
|
||||||
type FeedUri = string
|
type FeedUri = string
|
||||||
type ListUri = string
|
type ListUri = string
|
||||||
|
|
||||||
export type FeedDescriptor =
|
export type FeedDescriptor =
|
||||||
| 'home'
|
|
||||||
| 'following'
|
| 'following'
|
||||||
| `author|${ActorDid}|${AuthorFilter}`
|
| `author|${ActorDid}|${AuthorFilter}`
|
||||||
| `feedgen|${FeedUri}`
|
| `feedgen|${FeedUri}`
|
||||||
|
@ -390,7 +390,7 @@ function createApi({
|
||||||
userInterests?: string
|
userInterests?: string
|
||||||
getAgent: () => BskyAgent
|
getAgent: () => BskyAgent
|
||||||
}) {
|
}) {
|
||||||
if (feedDesc === 'home') {
|
if (feedDesc === 'following') {
|
||||||
if (feedParams.mergeFeedEnabled) {
|
if (feedParams.mergeFeedEnabled) {
|
||||||
return new MergeFeedAPI({
|
return new MergeFeedAPI({
|
||||||
getAgent,
|
getAgent,
|
||||||
|
@ -401,8 +401,6 @@ function createApi({
|
||||||
} else {
|
} else {
|
||||||
return new HomeFeedAPI({getAgent, userInterests})
|
return new HomeFeedAPI({getAgent, userInterests})
|
||||||
}
|
}
|
||||||
} else if (feedDesc === 'following') {
|
|
||||||
return new FollowingFeedAPI({getAgent})
|
|
||||||
} else if (feedDesc.startsWith('author')) {
|
} else if (feedDesc.startsWith('author')) {
|
||||||
const [_, actor, filter] = feedDesc.split('|')
|
const [_, actor, filter] = feedDesc.split('|')
|
||||||
return new AuthorFeedAPI({getAgent, feedParams: {actor, filter}})
|
return new AuthorFeedAPI({getAgent, feedParams: {actor, filter}})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import {
|
|
||||||
UsePreferencesQueryResponse,
|
|
||||||
ThreadViewPreferences,
|
|
||||||
} from '#/state/queries/preferences/types'
|
|
||||||
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
|
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
|
||||||
|
import {
|
||||||
|
ThreadViewPreferences,
|
||||||
|
UsePreferencesQueryResponse,
|
||||||
|
} from '#/state/queries/preferences/types'
|
||||||
|
|
||||||
export const DEFAULT_HOME_FEED_PREFS: UsePreferencesQueryResponse['feedViewPrefs'] =
|
export const DEFAULT_HOME_FEED_PREFS: UsePreferencesQueryResponse['feedViewPrefs'] =
|
||||||
{
|
{
|
||||||
|
@ -20,20 +20,8 @@ export const DEFAULT_THREAD_VIEW_PREFS: ThreadViewPreferences = {
|
||||||
lab_treeViewEnabled: false,
|
lab_treeViewEnabled: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_PROD_FEED_PREFIX = (rkey: string) =>
|
|
||||||
`at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}`
|
|
||||||
export const DEFAULT_PROD_FEEDS = {
|
|
||||||
pinned: [DEFAULT_PROD_FEED_PREFIX('whats-hot')],
|
|
||||||
saved: [DEFAULT_PROD_FEED_PREFIX('whats-hot')],
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
||||||
birthDate: new Date('2022-11-17'), // TODO(pwi)
|
birthDate: new Date('2022-11-17'), // TODO(pwi)
|
||||||
feeds: {
|
|
||||||
saved: [],
|
|
||||||
pinned: [],
|
|
||||||
unpinned: [],
|
|
||||||
},
|
|
||||||
moderationPrefs: {
|
moderationPrefs: {
|
||||||
adultContentEnabled: false,
|
adultContentEnabled: false,
|
||||||
labels: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
labels: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
||||||
|
@ -45,4 +33,5 @@ export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
||||||
threadViewPrefs: DEFAULT_THREAD_VIEW_PREFS,
|
threadViewPrefs: DEFAULT_THREAD_VIEW_PREFS,
|
||||||
userAge: 13, // TODO(pwi)
|
userAge: 13, // TODO(pwi)
|
||||||
interests: {tags: []},
|
interests: {tags: []},
|
||||||
|
savedFeeds: [],
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,14 +51,11 @@ export function usePreferencesQuery() {
|
||||||
|
|
||||||
const preferences: UsePreferencesQueryResponse = {
|
const preferences: UsePreferencesQueryResponse = {
|
||||||
...res,
|
...res,
|
||||||
feeds: {
|
savedFeeds: res.savedFeeds.filter(f => f.type !== 'unknown'),
|
||||||
saved: res.feeds?.saved || [],
|
/**
|
||||||
pinned: res.feeds?.pinned || [],
|
* Special preference, only used for following feed, previously
|
||||||
unpinned:
|
* called `home`
|
||||||
res.feeds.saved?.filter(f => {
|
*/
|
||||||
return !res.feeds.pinned?.includes(f)
|
|
||||||
}) || [],
|
|
||||||
},
|
|
||||||
feedViewPrefs: {
|
feedViewPrefs: {
|
||||||
...DEFAULT_HOME_FEED_PREFS,
|
...DEFAULT_HOME_FEED_PREFS,
|
||||||
...(res.feedViewPrefs.home || {}),
|
...(res.feedViewPrefs.home || {}),
|
||||||
|
@ -168,6 +165,10 @@ export function useSetFeedViewPreferencesMutation() {
|
||||||
|
|
||||||
return useMutation<void, unknown, Partial<BskyFeedViewPreference>>({
|
return useMutation<void, unknown, Partial<BskyFeedViewPreference>>({
|
||||||
mutationFn: async prefs => {
|
mutationFn: async prefs => {
|
||||||
|
/*
|
||||||
|
* special handling here, merged into `feedViewPrefs` above, since
|
||||||
|
* following was previously called `home`
|
||||||
|
*/
|
||||||
await getAgent().setFeedViewPrefs('home', prefs)
|
await getAgent().setFeedViewPrefs('home', prefs)
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
|
@ -192,17 +193,13 @@ export function useSetThreadViewPreferencesMutation() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSetSaveFeedsMutation() {
|
export function useOverwriteSavedFeedsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<
|
return useMutation<void, unknown, AppBskyActorDefs.SavedFeed[]>({
|
||||||
void,
|
mutationFn: async savedFeeds => {
|
||||||
unknown,
|
await getAgent().overwriteSavedFeeds(savedFeeds)
|
||||||
Pick<UsePreferencesQueryResponse['feeds'], 'saved' | 'pinned'>
|
|
||||||
>({
|
|
||||||
mutationFn: async ({saved, pinned}) => {
|
|
||||||
await getAgent().setSavedFeeds(saved, pinned)
|
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: preferencesQueryKey,
|
queryKey: preferencesQueryKey,
|
||||||
|
@ -211,13 +208,17 @@ export function useSetSaveFeedsMutation() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useSaveFeedMutation() {
|
export function useAddSavedFeedsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<
|
||||||
mutationFn: async ({uri}) => {
|
void,
|
||||||
await getAgent().addSavedFeed(uri)
|
unknown,
|
||||||
|
Pick<AppBskyActorDefs.SavedFeed, 'type' | 'value' | 'pinned'>[]
|
||||||
|
>({
|
||||||
|
mutationFn: async savedFeeds => {
|
||||||
|
await getAgent().addSavedFeeds(savedFeeds)
|
||||||
track('CustomFeed:Save')
|
track('CustomFeed:Save')
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
|
@ -231,9 +232,9 @@ export function useRemoveFeedMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, Pick<AppBskyActorDefs.SavedFeed, 'id'>>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async savedFeed => {
|
||||||
await getAgent().removeSavedFeed(uri)
|
await getAgent().removeSavedFeeds([savedFeed.id])
|
||||||
track('CustomFeed:Unsave')
|
track('CustomFeed:Unsave')
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
|
@ -243,30 +244,14 @@ export function useRemoveFeedMutation() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function usePinFeedMutation() {
|
export function useUpdateSavedFeedsMutation() {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
return useMutation<void, unknown, AppBskyActorDefs.SavedFeed[]>({
|
||||||
mutationFn: async ({uri}) => {
|
mutationFn: async feeds => {
|
||||||
await getAgent().addPinnedFeed(uri)
|
await getAgent().updateSavedFeeds(feeds)
|
||||||
track('CustomFeed:Pin', {uri})
|
|
||||||
// triggers a refetch
|
|
||||||
await queryClient.invalidateQueries({
|
|
||||||
queryKey: preferencesQueryKey,
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useUnpinFeedMutation() {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
const {getAgent} = useAgent()
|
|
||||||
|
|
||||||
return useMutation<void, unknown, {uri: string}>({
|
|
||||||
mutationFn: async ({uri}) => {
|
|
||||||
await getAgent().removePinnedFeed(uri)
|
|
||||||
track('CustomFeed:Unpin', {uri})
|
|
||||||
// triggers a refetch
|
// triggers a refetch
|
||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: preferencesQueryKey,
|
queryKey: preferencesQueryKey,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import {
|
import {
|
||||||
|
BskyFeedViewPreference,
|
||||||
BskyPreferences,
|
BskyPreferences,
|
||||||
BskyThreadViewPreference,
|
BskyThreadViewPreference,
|
||||||
BskyFeedViewPreference,
|
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
|
||||||
export type UsePreferencesQueryResponse = Omit<
|
export type UsePreferencesQueryResponse = Omit<
|
||||||
|
@ -16,9 +16,6 @@ export type UsePreferencesQueryResponse = Omit<
|
||||||
*/
|
*/
|
||||||
threadViewPrefs: ThreadViewPreferences
|
threadViewPrefs: ThreadViewPreferences
|
||||||
userAge: number | undefined
|
userAge: number | undefined
|
||||||
feeds: Required<BskyPreferences['feeds']> & {
|
|
||||||
unpinned: string[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ThreadViewPreferences = Pick<
|
export type ThreadViewPreferences = Pick<
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
import {AtpSessionData, AtpSessionEvent, BskyAgent} from '@atproto/api'
|
import {AtpSessionData, AtpSessionEvent, BskyAgent} from '@atproto/api'
|
||||||
|
import {TID} from '@atproto/common-web'
|
||||||
|
|
||||||
import {networkRetry} from '#/lib/async/retry'
|
import {networkRetry} from '#/lib/async/retry'
|
||||||
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
|
import {
|
||||||
import {IS_PROD_SERVICE} from '#/lib/constants'
|
DISCOVER_SAVED_FEED,
|
||||||
|
IS_PROD_SERVICE,
|
||||||
|
PUBLIC_BSKY_SERVICE,
|
||||||
|
TIMELINE_SAVED_FEED,
|
||||||
|
} from '#/lib/constants'
|
||||||
import {tryFetchGates} from '#/lib/statsig/statsig'
|
import {tryFetchGates} from '#/lib/statsig/statsig'
|
||||||
import {DEFAULT_PROD_FEEDS} from '../queries/preferences'
|
import {logger} from '#/logger'
|
||||||
import {
|
import {
|
||||||
configureModerationForAccount,
|
configureModerationForAccount,
|
||||||
configureModerationForGuest,
|
configureModerationForGuest,
|
||||||
|
@ -134,9 +139,28 @@ export async function createAgentAndCreateAccount(
|
||||||
|
|
||||||
// Not awaited so that we can still get into onboarding.
|
// Not awaited so that we can still get into onboarding.
|
||||||
// This is OK because we won't let you toggle adult stuff until you set the date.
|
// This is OK because we won't let you toggle adult stuff until you set the date.
|
||||||
agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
|
||||||
if (IS_PROD_SERVICE(service)) {
|
if (IS_PROD_SERVICE(service)) {
|
||||||
agent.setSavedFeeds(DEFAULT_PROD_FEEDS.saved, DEFAULT_PROD_FEEDS.pinned)
|
try {
|
||||||
|
networkRetry(1, async () => {
|
||||||
|
await agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
||||||
|
await agent.overwriteSavedFeeds([
|
||||||
|
{
|
||||||
|
...DISCOVER_SAVED_FEED,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...TIMELINE_SAVED_FEED,
|
||||||
|
id: TID.nextStr(),
|
||||||
|
},
|
||||||
|
])
|
||||||
|
})
|
||||||
|
} catch (e: any) {
|
||||||
|
logger.error(e, {
|
||||||
|
context: `session: createAgentAndCreateAccount failed to save personal details and feeds`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
||||||
}
|
}
|
||||||
|
|
||||||
return prepareAgent(agent, gates, moderation, onSessionChange)
|
return prepareAgent(agent, gates, moderation, onSessionChange)
|
||||||
|
|
|
@ -1,47 +1,46 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {Gate} from '#/lib/statsig/gates'
|
|
||||||
import {useGate} from '#/lib/statsig/statsig'
|
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
import {FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
|
|
||||||
type StateContext = string
|
type StateContext = FeedDescriptor | null
|
||||||
type SetContext = (v: string) => void
|
type SetContext = (v: FeedDescriptor) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>('home')
|
const stateContext = React.createContext<StateContext>(null)
|
||||||
const setContext = React.createContext<SetContext>((_: string) => {})
|
const setContext = React.createContext<SetContext>((_: string) => {})
|
||||||
|
|
||||||
function getInitialFeed(gate: (gateName: Gate) => boolean) {
|
function getInitialFeed(): FeedDescriptor | null {
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
if (window.location.pathname === '/') {
|
if (window.location.pathname === '/') {
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
const feedFromUrl = params.get('feed')
|
const feedFromUrl = params.get('feed')
|
||||||
if (feedFromUrl) {
|
if (feedFromUrl) {
|
||||||
// If explicitly booted from a link like /?feed=..., prefer that.
|
// If explicitly booted from a link like /?feed=..., prefer that.
|
||||||
return feedFromUrl
|
return feedFromUrl as FeedDescriptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const feedFromSession = sessionStorage.getItem('lastSelectedHomeFeed')
|
const feedFromSession = sessionStorage.getItem('lastSelectedHomeFeed')
|
||||||
if (feedFromSession) {
|
if (feedFromSession) {
|
||||||
// Fall back to a previously chosen feed for this browser tab.
|
// Fall back to a previously chosen feed for this browser tab.
|
||||||
return feedFromSession
|
return feedFromSession as FeedDescriptor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gate('start_session_with_following_v2')) {
|
|
||||||
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
|
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
|
||||||
if (feedFromPersisted) {
|
if (feedFromPersisted) {
|
||||||
// Fall back to the last chosen one across all tabs.
|
// Fall back to the last chosen one across all tabs.
|
||||||
return feedFromPersisted
|
return feedFromPersisted as FeedDescriptor
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 'home'
|
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const gate = useGate()
|
const [state, setState] = React.useState(() => getInitialFeed())
|
||||||
const [state, setState] = React.useState(() => getInitialFeed(gate))
|
|
||||||
|
|
||||||
const saveState = React.useCallback((feed: string) => {
|
const saveState = React.useCallback((feed: FeedDescriptor) => {
|
||||||
setState(feed)
|
setState(feed)
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {useWindowDimensions, View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
@ -17,9 +18,9 @@ import {useSession} from '#/state/session'
|
||||||
import {useSetMinimalShellMode} from '#/state/shell'
|
import {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'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
|
||||||
import {ComposeIcon2} from 'lib/icons'
|
import {ComposeIcon2} from 'lib/icons'
|
||||||
import {s} from 'lib/styles'
|
import {s} from 'lib/styles'
|
||||||
|
import {useHeaderOffset} from '#/components/hooks/useHeaderOffset'
|
||||||
import {Feed} from '../posts/Feed'
|
import {Feed} from '../posts/Feed'
|
||||||
import {FAB} from '../util/fab/FAB'
|
import {FAB} from '../util/fab/FAB'
|
||||||
import {ListMethods} from '../util/List'
|
import {ListMethods} from '../util/List'
|
||||||
|
@ -35,6 +36,7 @@ export function FeedPage({
|
||||||
feedParams,
|
feedParams,
|
||||||
renderEmptyState,
|
renderEmptyState,
|
||||||
renderEndOfFeed,
|
renderEndOfFeed,
|
||||||
|
savedFeedConfig,
|
||||||
}: {
|
}: {
|
||||||
testID?: string
|
testID?: string
|
||||||
feed: FeedDescriptor
|
feed: FeedDescriptor
|
||||||
|
@ -42,6 +44,7 @@ export function FeedPage({
|
||||||
isPageFocused: boolean
|
isPageFocused: boolean
|
||||||
renderEmptyState: () => JSX.Element
|
renderEmptyState: () => JSX.Element
|
||||||
renderEndOfFeed?: () => JSX.Element
|
renderEndOfFeed?: () => JSX.Element
|
||||||
|
savedFeedConfig?: AppBskyActorDefs.SavedFeed
|
||||||
}) {
|
}) {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
@ -129,6 +132,7 @@ export function FeedPage({
|
||||||
renderEmptyState={renderEmptyState}
|
renderEmptyState={renderEmptyState}
|
||||||
renderEndOfFeed={renderEndOfFeed}
|
renderEndOfFeed={renderEndOfFeed}
|
||||||
headerOffset={headerOffset}
|
headerOffset={headerOffset}
|
||||||
|
savedFeedConfig={savedFeedConfig}
|
||||||
/>
|
/>
|
||||||
</FeedFeedbackProvider>
|
</FeedFeedbackProvider>
|
||||||
</MainScrollProvider>
|
</MainScrollProvider>
|
||||||
|
@ -153,16 +157,3 @@ export function FeedPage({
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function useHeaderOffset() {
|
|
||||||
const {isDesktop, isTablet} = useWebMediaQueries()
|
|
||||||
const {fontScale} = useWindowDimensions()
|
|
||||||
if (isDesktop || isTablet) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
const navBarHeight = 42
|
|
||||||
const tabBarPad = 10 + 10 + 3 // padding + border
|
|
||||||
const normalLineHeight = 1.2
|
|
||||||
const tabBarText = 16 * normalLineHeight * fontScale
|
|
||||||
return navBarHeight + tabBarPad + tabBarText
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,29 +1,30 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Pressable, StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
import {Pressable, StyleProp, StyleSheet, View, ViewStyle} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {RichText} from '#/components/RichText'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
import {s} from 'lib/styles'
|
|
||||||
import {UserAvatar} from '../util/UserAvatar'
|
|
||||||
import {AtUri} from '@atproto/api'
|
import {AtUri} from '@atproto/api'
|
||||||
import * as Toast from 'view/com/util/Toast'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {sanitizeHandle} from 'lib/strings/handles'
|
import {msg, Plural, Trans} from '@lingui/macro'
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {Trans, msg, Plural} from '@lingui/macro'
|
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {logger} from '#/logger'
|
||||||
|
import {FeedSourceInfo, useFeedSourceInfoQuery} from '#/state/queries/feed'
|
||||||
import {
|
import {
|
||||||
usePinFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
UsePreferencesQueryResponse,
|
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
useSaveFeedMutation,
|
UsePreferencesQueryResponse,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useFeedSourceInfoQuery, FeedSourceInfo} from '#/state/queries/feed'
|
|
||||||
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
|
||||||
import {useTheme} from '#/alf'
|
|
||||||
import * as Prompt from '#/components/Prompt'
|
|
||||||
import {useNavigationDeduped} from 'lib/hooks/useNavigationDeduped'
|
import {useNavigationDeduped} from 'lib/hooks/useNavigationDeduped'
|
||||||
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {sanitizeHandle} from 'lib/strings/handles'
|
||||||
|
import {s} from 'lib/styles'
|
||||||
|
import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
||||||
|
import * as Toast from 'view/com/util/Toast'
|
||||||
|
import {useTheme} from '#/alf'
|
||||||
|
import {atoms as a} from '#/alf'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
|
import {RichText} from '#/components/RichText'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
|
import {UserAvatar} from '../util/UserAvatar'
|
||||||
|
|
||||||
export function FeedSourceCard({
|
export function FeedSourceCard({
|
||||||
feedUri,
|
feedUri,
|
||||||
|
@ -87,53 +88,54 @@ export function FeedSourceCardLoaded({
|
||||||
const removePromptControl = Prompt.usePromptControl()
|
const removePromptControl = Prompt.usePromptControl()
|
||||||
const navigation = useNavigationDeduped()
|
const navigation = useNavigationDeduped()
|
||||||
|
|
||||||
const {isPending: isSavePending, mutateAsync: saveFeed} =
|
const {isPending: isAddSavedFeedPending, mutateAsync: addSavedFeeds} =
|
||||||
useSaveFeedMutation()
|
useAddSavedFeedsMutation()
|
||||||
const {isPending: isRemovePending, mutateAsync: removeFeed} =
|
const {isPending: isRemovePending, mutateAsync: removeFeed} =
|
||||||
useRemoveFeedMutation()
|
useRemoveFeedMutation()
|
||||||
const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation()
|
|
||||||
|
|
||||||
const isSaved = Boolean(preferences?.feeds?.saved?.includes(feed?.uri || ''))
|
const savedFeedConfig = preferences?.savedFeeds?.find(
|
||||||
|
f => f.value === feed?.uri,
|
||||||
|
)
|
||||||
|
const isSaved = Boolean(savedFeedConfig)
|
||||||
|
|
||||||
const onSave = React.useCallback(async () => {
|
const onSave = React.useCallback(async () => {
|
||||||
if (!feed) return
|
if (!feed || isSaved) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (pinOnSave) {
|
await addSavedFeeds([
|
||||||
await pinFeed({uri: feed.uri})
|
{
|
||||||
} else {
|
type: 'feed',
|
||||||
await saveFeed({uri: feed.uri})
|
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, pinFeed, pinOnSave, saveFeed])
|
}, [_, feed, pinOnSave, addSavedFeeds, isSaved])
|
||||||
|
|
||||||
const onUnsave = React.useCallback(async () => {
|
const onUnsave = React.useCallback(async () => {
|
||||||
if (!feed) return
|
if (!savedFeedConfig) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await removeFeed({uri: feed.uri})
|
await removeFeed(savedFeedConfig)
|
||||||
// await item.unsave()
|
// await item.unsave()
|
||||||
Toast.show(_(msg`Removed from my feeds`))
|
Toast.show(_(msg`Removed from 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 unsave feed', {message: e})
|
logger.error('Failed to unsave feed', {message: e})
|
||||||
}
|
}
|
||||||
}, [_, feed, removeFeed])
|
}, [_, removeFeed, savedFeedConfig])
|
||||||
|
|
||||||
const onToggleSaved = React.useCallback(async () => {
|
const onToggleSaved = React.useCallback(async () => {
|
||||||
// Only feeds can be un/saved, lists are handled elsewhere
|
|
||||||
if (feed?.type !== 'feed') return
|
|
||||||
|
|
||||||
if (isSaved) {
|
if (isSaved) {
|
||||||
removePromptControl.open()
|
removePromptControl.open()
|
||||||
} else {
|
} else {
|
||||||
await onSave()
|
await onSave()
|
||||||
}
|
}
|
||||||
}, [feed?.type, isSaved, removePromptControl, onSave])
|
}, [isSaved, removePromptControl, onSave])
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* LOAD STATE
|
* LOAD STATE
|
||||||
|
@ -204,7 +206,7 @@ export function FeedSourceCardLoaded({
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
key={feed.uri}>
|
key={feed.uri}>
|
||||||
<View style={[styles.headerContainer]}>
|
<View style={[styles.headerContainer, a.align_start]}>
|
||||||
<View style={[s.mr10]}>
|
<View style={[s.mr10]}>
|
||||||
<UserAvatar type="algo" size={36} avatar={feed.avatar} />
|
<UserAvatar type="algo" size={36} avatar={feed.avatar} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -221,11 +223,11 @@ export function FeedSourceCardLoaded({
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{showSaveBtn && feed.type === 'feed' && (
|
{showSaveBtn && (
|
||||||
<View style={[s.justifyCenter]}>
|
<View style={[s.justifyCenter]}>
|
||||||
<Pressable
|
<Pressable
|
||||||
testID={`feed-${feed.displayName}-toggleSave`}
|
testID={`feed-${feed.displayName}-toggleSave`}
|
||||||
disabled={isSavePending || isPinPending || isRemovePending}
|
disabled={isAddSavedFeedPending || isRemovePending}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
accessibilityLabel={
|
accessibilityLabel={
|
||||||
isSaved
|
isSaved
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {RenderTabBarFnProps} from 'view/com/pager/Pager'
|
|
||||||
import {HomeHeaderLayout} from './HomeHeaderLayout'
|
|
||||||
import {FeedSourceInfo} from '#/state/queries/feed'
|
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
|
import {usePalette} from '#/lib/hooks/usePalette'
|
||||||
|
import {FeedSourceInfo} from '#/state/queries/feed'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import {NavigationProp} from 'lib/routes/types'
|
import {NavigationProp} from 'lib/routes/types'
|
||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
|
import {RenderTabBarFnProps} from 'view/com/pager/Pager'
|
||||||
import {TabBar} from '../pager/TabBar'
|
import {TabBar} from '../pager/TabBar'
|
||||||
import {usePalette} from '#/lib/hooks/usePalette'
|
import {HomeHeaderLayout} from './HomeHeaderLayout'
|
||||||
|
|
||||||
export function HomeHeader(
|
export function HomeHeader(
|
||||||
props: RenderTabBarFnProps & {
|
props: RenderTabBarFnProps & {
|
||||||
|
@ -16,12 +18,17 @@ export function HomeHeader(
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const {feeds} = props
|
const {feeds} = props
|
||||||
|
const {hasSession} = useSession()
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
|
||||||
const hasPinnedCustom = React.useMemo<boolean>(() => {
|
const hasPinnedCustom = React.useMemo<boolean>(() => {
|
||||||
return feeds.some(tab => tab.uri !== '')
|
if (!hasSession) return false
|
||||||
}, [feeds])
|
return feeds.some(tab => {
|
||||||
|
const isFollowing = tab.uri === 'following'
|
||||||
|
return !isFollowing
|
||||||
|
})
|
||||||
|
}, [feeds, hasSession])
|
||||||
|
|
||||||
const items = React.useMemo(() => {
|
const items = React.useMemo(() => {
|
||||||
const pinnedNames = feeds.map(f => f.displayName)
|
const pinnedNames = feeds.map(f => f.displayName)
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {LayoutAnimation, StyleSheet, View} from 'react-native'
|
import {LayoutAnimation, StyleSheet, View} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
|
||||||
import ImageView from './ImageViewing'
|
|
||||||
import {shareImageModal, saveImageToMediaLibrary} from 'lib/media/manip'
|
|
||||||
import * as Toast from '../util/Toast'
|
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {s, colors} from 'lib/styles'
|
|
||||||
import {Button} from '../util/forms/Button'
|
|
||||||
import {isIOS} from 'platform/detection'
|
|
||||||
import * as MediaLibrary from 'expo-media-library'
|
import * as MediaLibrary from 'expo-media-library'
|
||||||
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
ImagesLightbox,
|
||||||
|
ProfileImageLightbox,
|
||||||
useLightbox,
|
useLightbox,
|
||||||
useLightboxControls,
|
useLightboxControls,
|
||||||
ProfileImageLightbox,
|
|
||||||
ImagesLightbox,
|
|
||||||
} from '#/state/lightbox'
|
} from '#/state/lightbox'
|
||||||
import {Trans, msg} from '@lingui/macro'
|
import {saveImageToMediaLibrary, shareImageModal} from 'lib/media/manip'
|
||||||
import {useLingui} from '@lingui/react'
|
import {colors, s} from 'lib/styles'
|
||||||
|
import {isIOS} from 'platform/detection'
|
||||||
|
import {Button} from '../util/forms/Button'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
|
import * as Toast from '../util/Toast'
|
||||||
|
import ImageView from './ImageViewing'
|
||||||
|
|
||||||
export function Lightbox() {
|
export function Lightbox() {
|
||||||
const {activeLightbox} = useLightbox()
|
const {activeLightbox} = useLightbox()
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import React, {useState} from 'react'
|
import React, {useState} from 'react'
|
||||||
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
import {StyleSheet, TouchableOpacity, View} from 'react-native'
|
||||||
import {Text} from '../util/text/Text'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {s, colors} from 'lib/styles'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useModalControls} from '#/state/modals'
|
||||||
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 {colors, s} from 'lib/styles'
|
||||||
import {isWeb} from 'platform/detection'
|
import {isWeb} from 'platform/detection'
|
||||||
|
import {ScrollView} from 'view/com/modals/util'
|
||||||
import {Button} from '../util/forms/Button'
|
import {Button} from '../util/forms/Button'
|
||||||
import {SelectableBtn} from '../util/forms/SelectableBtn'
|
import {SelectableBtn} from '../util/forms/SelectableBtn'
|
||||||
import {ScrollView} from 'view/com/modals/util'
|
import {Text} from '../util/text/Text'
|
||||||
import {Trans, msg} from '@lingui/macro'
|
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {useModalControls} from '#/state/modals'
|
|
||||||
|
|
||||||
const ADULT_CONTENT_LABELS = ['sexual', 'nudity', 'porn']
|
const ADULT_CONTENT_LABELS = ['sexual', 'nudity', 'porn']
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import React, {useRef, useMemo, useEffect, useState, useCallback} from 'react'
|
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'
|
||||||
import {StyleSheet, View, ScrollView, LayoutChangeEvent} from 'react-native'
|
import {LayoutChangeEvent, ScrollView, StyleSheet, View} from 'react-native'
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {PressableWithHover} from '../util/PressableWithHover'
|
import {isNative} from '#/platform/detection'
|
||||||
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 {PressableWithHover} from '../util/PressableWithHover'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
import {DraggableScrollView} from './DraggableScrollView'
|
import {DraggableScrollView} from './DraggableScrollView'
|
||||||
import {isNative} from '#/platform/detection'
|
|
||||||
|
|
||||||
export interface TabBarProps {
|
export interface TabBarProps {
|
||||||
testID?: string
|
testID?: string
|
||||||
|
@ -139,7 +140,10 @@ export function TabBar({
|
||||||
<Text
|
<Text
|
||||||
type={isDesktop || isTablet ? 'xl-bold' : 'lg-bold'}
|
type={isDesktop || isTablet ? 'xl-bold' : 'lg-bold'}
|
||||||
testID={testID ? `${testID}-${item}` : undefined}
|
testID={testID ? `${testID}-${item}` : undefined}
|
||||||
style={selected ? pal.text : pal.textLight}>
|
style={[
|
||||||
|
selected ? pal.text : pal.textLight,
|
||||||
|
{lineHeight: 20},
|
||||||
|
]}>
|
||||||
{item}
|
{item}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
View,
|
View,
|
||||||
ViewStyle,
|
ViewStyle,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useQueryClient} from '@tanstack/react-query'
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
@ -64,6 +65,7 @@ let Feed = ({
|
||||||
desktopFixedHeightOffset,
|
desktopFixedHeightOffset,
|
||||||
ListHeaderComponent,
|
ListHeaderComponent,
|
||||||
extraData,
|
extraData,
|
||||||
|
savedFeedConfig,
|
||||||
}: {
|
}: {
|
||||||
feed: FeedDescriptor
|
feed: FeedDescriptor
|
||||||
feedParams?: FeedParams
|
feedParams?: FeedParams
|
||||||
|
@ -82,6 +84,7 @@ let Feed = ({
|
||||||
desktopFixedHeightOffset?: number
|
desktopFixedHeightOffset?: number
|
||||||
ListHeaderComponent?: () => JSX.Element
|
ListHeaderComponent?: () => JSX.Element
|
||||||
extraData?: any
|
extraData?: any
|
||||||
|
savedFeedConfig?: AppBskyActorDefs.SavedFeed
|
||||||
}): React.ReactNode => {
|
}): React.ReactNode => {
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
|
@ -140,7 +143,6 @@ let Feed = ({
|
||||||
if (
|
if (
|
||||||
data?.pages.length === 1 &&
|
data?.pages.length === 1 &&
|
||||||
(feed === 'following' ||
|
(feed === 'following' ||
|
||||||
feed === 'home' ||
|
|
||||||
feed === `author|${myDid}|posts_and_author_threads`)
|
feed === `author|${myDid}|posts_and_author_threads`)
|
||||||
) {
|
) {
|
||||||
queryClient.invalidateQueries({queryKey: RQKEY(feed)})
|
queryClient.invalidateQueries({queryKey: RQKEY(feed)})
|
||||||
|
@ -280,6 +282,7 @@ let Feed = ({
|
||||||
feedDesc={feed}
|
feedDesc={feed}
|
||||||
error={error ?? undefined}
|
error={error ?? undefined}
|
||||||
onPressTryAgain={onPressTryAgain}
|
onPressTryAgain={onPressTryAgain}
|
||||||
|
savedFeedConfig={savedFeedConfig}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else if (item === LOAD_MORE_ERROR_ITEM) {
|
} else if (item === LOAD_MORE_ERROR_ITEM) {
|
||||||
|
@ -302,7 +305,15 @@ let Feed = ({
|
||||||
}
|
}
|
||||||
return <FeedSlice slice={item} />
|
return <FeedSlice slice={item} />
|
||||||
},
|
},
|
||||||
[feed, error, onPressTryAgain, onPressRetryLoadMore, renderEmptyState, _],
|
[
|
||||||
|
feed,
|
||||||
|
error,
|
||||||
|
onPressTryAgain,
|
||||||
|
onPressRetryLoadMore,
|
||||||
|
renderEmptyState,
|
||||||
|
_,
|
||||||
|
savedFeedConfig,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
const shouldRenderEndOfFeed =
|
const shouldRenderEndOfFeed =
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {AppBskyFeedGetAuthorFeed, AtUri} from '@atproto/api'
|
import {AppBskyActorDefs, AppBskyFeedGetAuthorFeed, AtUri} from '@atproto/api'
|
||||||
import {Text} from '../util/text/Text'
|
|
||||||
import {Button} from '../util/forms/Button'
|
|
||||||
import * as Toast from '../util/Toast'
|
|
||||||
import {ErrorMessage} from '../util/error/ErrorMessage'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
import {useNavigation} from '@react-navigation/native'
|
|
||||||
import {NavigationProp} from 'lib/routes/types'
|
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {msg as msgLingui, Trans} from '@lingui/macro'
|
import {msg as msgLingui, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {FeedDescriptor} from '#/state/queries/post-feed'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
import {EmptyState} from '../util/EmptyState'
|
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
|
import {logger} from '#/logger'
|
||||||
|
import {FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
import {useRemoveFeedMutation} from '#/state/queries/preferences'
|
import {useRemoveFeedMutation} from '#/state/queries/preferences'
|
||||||
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {NavigationProp} from 'lib/routes/types'
|
||||||
import * as Prompt from '#/components/Prompt'
|
import * as Prompt from '#/components/Prompt'
|
||||||
|
import {EmptyState} from '../util/EmptyState'
|
||||||
|
import {ErrorMessage} from '../util/error/ErrorMessage'
|
||||||
|
import {Button} from '../util/forms/Button'
|
||||||
|
import {Text} from '../util/text/Text'
|
||||||
|
import * as Toast from '../util/Toast'
|
||||||
|
|
||||||
export enum KnownError {
|
export enum KnownError {
|
||||||
Block = 'Block',
|
Block = 'Block',
|
||||||
|
@ -33,10 +34,12 @@ export function FeedErrorMessage({
|
||||||
feedDesc,
|
feedDesc,
|
||||||
error,
|
error,
|
||||||
onPressTryAgain,
|
onPressTryAgain,
|
||||||
|
savedFeedConfig,
|
||||||
}: {
|
}: {
|
||||||
feedDesc: FeedDescriptor
|
feedDesc: FeedDescriptor
|
||||||
error?: Error
|
error?: Error
|
||||||
onPressTryAgain: () => void
|
onPressTryAgain: () => void
|
||||||
|
savedFeedConfig?: AppBskyActorDefs.SavedFeed
|
||||||
}) {
|
}) {
|
||||||
const {_: _l} = useLingui()
|
const {_: _l} = useLingui()
|
||||||
const knownError = React.useMemo(
|
const knownError = React.useMemo(
|
||||||
|
@ -46,13 +49,15 @@ export function FeedErrorMessage({
|
||||||
if (
|
if (
|
||||||
typeof knownError !== 'undefined' &&
|
typeof knownError !== 'undefined' &&
|
||||||
knownError !== KnownError.Unknown &&
|
knownError !== KnownError.Unknown &&
|
||||||
(feedDesc.startsWith('feedgen') || knownError === KnownError.FeedNSFPublic)
|
(savedFeedConfig?.type === 'feed' ||
|
||||||
|
knownError === KnownError.FeedNSFPublic)
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<FeedgenErrorMessage
|
<FeedgenErrorMessage
|
||||||
feedDesc={feedDesc}
|
feedDesc={feedDesc}
|
||||||
knownError={knownError}
|
knownError={knownError}
|
||||||
rawError={error}
|
rawError={error}
|
||||||
|
savedFeedConfig={savedFeedConfig}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -79,10 +84,12 @@ function FeedgenErrorMessage({
|
||||||
feedDesc,
|
feedDesc,
|
||||||
knownError,
|
knownError,
|
||||||
rawError,
|
rawError,
|
||||||
|
savedFeedConfig,
|
||||||
}: {
|
}: {
|
||||||
feedDesc: FeedDescriptor
|
feedDesc: FeedDescriptor
|
||||||
knownError: KnownError
|
knownError: KnownError
|
||||||
rawError?: Error
|
rawError?: Error
|
||||||
|
savedFeedConfig?: AppBskyActorDefs.SavedFeed
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {_: _l} = useLingui()
|
const {_: _l} = useLingui()
|
||||||
|
@ -131,7 +138,8 @@ function FeedgenErrorMessage({
|
||||||
|
|
||||||
const onRemoveFeed = React.useCallback(async () => {
|
const onRemoveFeed = React.useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
await removeFeed({uri})
|
if (!savedFeedConfig) return
|
||||||
|
await removeFeed(savedFeedConfig)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
_l(
|
_l(
|
||||||
|
@ -140,7 +148,7 @@ function FeedgenErrorMessage({
|
||||||
)
|
)
|
||||||
logger.error('Failed to remove feed', {message: err})
|
logger.error('Failed to remove feed', {message: err})
|
||||||
}
|
}
|
||||||
}, [uri, removeFeed, _l])
|
}, [removeFeed, _l, savedFeedConfig])
|
||||||
|
|
||||||
const cta = React.useMemo(() => {
|
const cta = React.useMemo(() => {
|
||||||
switch (knownError) {
|
switch (knownError) {
|
||||||
|
@ -154,13 +162,14 @@ function FeedgenErrorMessage({
|
||||||
case KnownError.FeedgenUnknown: {
|
case KnownError.FeedgenUnknown: {
|
||||||
return (
|
return (
|
||||||
<View style={{flexDirection: 'row', alignItems: 'center', gap: 10}}>
|
<View style={{flexDirection: 'row', alignItems: 'center', gap: 10}}>
|
||||||
{knownError === KnownError.FeedgenDoesNotExist && (
|
{knownError === KnownError.FeedgenDoesNotExist &&
|
||||||
<Button
|
savedFeedConfig && (
|
||||||
type="inverted"
|
<Button
|
||||||
label={_l(msgLingui`Remove feed`)}
|
type="inverted"
|
||||||
onPress={onRemoveFeed}
|
label={_l(msgLingui`Remove feed`)}
|
||||||
/>
|
onPress={onRemoveFeed}
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
type="default-light"
|
type="default-light"
|
||||||
label={_l(msgLingui`View profile`)}
|
label={_l(msgLingui`View profile`)}
|
||||||
|
@ -170,7 +179,7 @@ function FeedgenErrorMessage({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [knownError, onViewProfile, onRemoveFeed, _l])
|
}, [knownError, onViewProfile, onRemoveFeed, _l, savedFeedConfig])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import React, {memo, useCallback} from 'react'
|
import React, {memo, useCallback} from 'react'
|
||||||
import {StyleProp, StyleSheet, TouchableOpacity, ViewStyle} from 'react-native'
|
import {StyleProp, StyleSheet, TouchableOpacity, ViewStyle} from 'react-native'
|
||||||
import {RepostIcon} from 'lib/icons'
|
|
||||||
import {s, colors} from 'lib/styles'
|
|
||||||
import {useTheme} from 'lib/ThemeContext'
|
|
||||||
import {Text} from '../text/Text'
|
|
||||||
import {HITSLOP_10, HITSLOP_20} from 'lib/constants'
|
|
||||||
import {useModalControls} from '#/state/modals'
|
|
||||||
import {useRequireAuth} from '#/state/session'
|
|
||||||
import {msg, plural} from '@lingui/macro'
|
import {msg, plural} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useModalControls} from '#/state/modals'
|
||||||
|
import {useRequireAuth} from '#/state/session'
|
||||||
|
import {HITSLOP_10, HITSLOP_20} from 'lib/constants'
|
||||||
|
import {RepostIcon} from 'lib/icons'
|
||||||
|
import {colors, s} from 'lib/styles'
|
||||||
|
import {useTheme} from 'lib/ThemeContext'
|
||||||
|
import {Text} from '../text/Text'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isReposted: boolean
|
isReposted: boolean
|
||||||
repostCount?: number
|
repostCount?: number
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
@ -44,8 +45,11 @@ import {
|
||||||
import {Text} from 'view/com/util/text/Text'
|
import {Text} from 'view/com/util/text/Text'
|
||||||
import {UserAvatar} from 'view/com/util/UserAvatar'
|
import {UserAvatar} from 'view/com/util/UserAvatar'
|
||||||
import {ViewHeader} from 'view/com/util/ViewHeader'
|
import {ViewHeader} from 'view/com/util/ViewHeader'
|
||||||
|
import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed'
|
||||||
|
import {NoSavedFeedsOfAnyType} from '#/screens/Feeds/NoSavedFeedsOfAnyType'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {IconCircle} from '#/components/IconCircle'
|
import {IconCircle} from '#/components/IconCircle'
|
||||||
|
import {FilterTimeline_Stroke2_Corner0_Rounded as FilterTimeline} from '#/components/icons/FilterTimeline'
|
||||||
import {ListMagnifyingGlass_Stroke2_Corner0_Rounded} from '#/components/icons/ListMagnifyingGlass'
|
import {ListMagnifyingGlass_Stroke2_Corner0_Rounded} from '#/components/icons/ListMagnifyingGlass'
|
||||||
import {ListSparkle_Stroke2_Corner0_Rounded} from '#/components/icons/ListSparkle'
|
import {ListSparkle_Stroke2_Corner0_Rounded} from '#/components/icons/ListSparkle'
|
||||||
|
|
||||||
|
@ -74,6 +78,7 @@ type FlatlistSlice =
|
||||||
type: 'savedFeed'
|
type: 'savedFeed'
|
||||||
key: string
|
key: string
|
||||||
feedUri: string
|
feedUri: string
|
||||||
|
savedFeedConfig: AppBskyActorDefs.SavedFeed
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'savedFeedsLoadMore'
|
type: 'savedFeedsLoadMore'
|
||||||
|
@ -100,6 +105,10 @@ type FlatlistSlice =
|
||||||
type: 'popularFeedsLoadingMore'
|
type: 'popularFeedsLoadingMore'
|
||||||
key: string
|
key: string
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: 'noFollowingFeed'
|
||||||
|
key: string
|
||||||
|
}
|
||||||
|
|
||||||
// HACK
|
// HACK
|
||||||
// the protocol doesn't yet tell us which feeds are personalized
|
// the protocol doesn't yet tell us which feeds are personalized
|
||||||
|
@ -229,33 +238,54 @@ export function FeedsScreen(_props: Props) {
|
||||||
error: cleanError(preferencesError.toString()),
|
error: cleanError(preferencesError.toString()),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (isPreferencesLoading || !preferences?.feeds?.saved) {
|
if (isPreferencesLoading || !preferences?.savedFeeds) {
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'savedFeedsLoading',
|
key: 'savedFeedsLoading',
|
||||||
type: 'savedFeedsLoading',
|
type: 'savedFeedsLoading',
|
||||||
// pendingItems: this.rootStore.preferences.savedFeeds.length || 3,
|
// pendingItems: this.rootStore.preferences.savedFeeds.length || 3,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (preferences?.feeds?.saved.length !== 0) {
|
if (preferences.savedFeeds?.length) {
|
||||||
const {saved, pinned} = preferences.feeds
|
const noFollowingFeed = preferences.savedFeeds.every(
|
||||||
|
f => f.type !== 'timeline',
|
||||||
slices = slices.concat(
|
|
||||||
pinned.map(uri => ({
|
|
||||||
key: `savedFeed:${uri}`,
|
|
||||||
type: 'savedFeed',
|
|
||||||
feedUri: uri,
|
|
||||||
})),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
slices = slices.concat(
|
slices = slices.concat(
|
||||||
saved
|
preferences.savedFeeds
|
||||||
.filter(uri => !pinned.includes(uri))
|
.filter(f => {
|
||||||
.map(uri => ({
|
return f.pinned
|
||||||
key: `savedFeed:${uri}`,
|
})
|
||||||
|
.map(feed => ({
|
||||||
|
key: `savedFeed:${feed.value}:${feed.id}`,
|
||||||
type: 'savedFeed',
|
type: 'savedFeed',
|
||||||
feedUri: uri,
|
feedUri: feed.value,
|
||||||
|
savedFeedConfig: feed,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
slices = slices.concat(
|
||||||
|
preferences.savedFeeds
|
||||||
|
.filter(f => {
|
||||||
|
return !f.pinned
|
||||||
|
})
|
||||||
|
.map(feed => ({
|
||||||
|
key: `savedFeed:${feed.value}:${feed.id}`,
|
||||||
|
type: 'savedFeed',
|
||||||
|
feedUri: feed.value,
|
||||||
|
savedFeedConfig: feed,
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
|
||||||
|
if (noFollowingFeed) {
|
||||||
|
slices.push({
|
||||||
|
key: 'noFollowingFeed',
|
||||||
|
type: 'noFollowingFeed',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
slices.push({
|
||||||
|
key: 'savedFeedNoResults',
|
||||||
|
type: 'savedFeedNoResults',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +353,12 @@ export function FeedsScreen(_props: Props) {
|
||||||
) {
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return !preferences?.feeds?.saved.includes(feed.uri)
|
const alreadySaved = Boolean(
|
||||||
|
preferences?.savedFeeds?.find(f => {
|
||||||
|
return f.value === feed.uri
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
return !alreadySaved
|
||||||
})
|
})
|
||||||
.map(feed => ({
|
.map(feed => ({
|
||||||
key: `popularFeed:${feed.uri}`,
|
key: `popularFeed:${feed.uri}`,
|
||||||
|
@ -463,23 +498,23 @@ export function FeedsScreen(_props: Props) {
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{preferences?.feeds?.saved?.length !== 0 && <FeedsSavedHeader />}
|
<FeedsSavedHeader />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
} else if (item.type === 'savedFeedNoResults') {
|
} else if (item.type === 'savedFeedNoResults') {
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={[
|
||||||
paddingHorizontal: 16,
|
pal.border,
|
||||||
paddingTop: 10,
|
{
|
||||||
}}>
|
borderBottomWidth: 1,
|
||||||
<Text type="lg" style={pal.textLight}>
|
},
|
||||||
<Trans>You don't have any saved feeds!</Trans>
|
]}>
|
||||||
</Text>
|
<NoSavedFeedsOfAnyType />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
} else if (item.type === 'savedFeed') {
|
} else if (item.type === 'savedFeed') {
|
||||||
return <SavedFeed feedUri={item.feedUri} />
|
return <FeedOrFollowing savedFeedConfig={item.savedFeedConfig} />
|
||||||
} else if (item.type === 'popularFeedsHeader') {
|
} else if (item.type === 'popularFeedsHeader') {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -521,6 +556,18 @@ export function FeedsScreen(_props: Props) {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
} else if (item.type === 'noFollowingFeed') {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
pal.border,
|
||||||
|
{
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<NoFollowingFeed />
|
||||||
|
</View>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
@ -532,7 +579,6 @@ export function FeedsScreen(_props: Props) {
|
||||||
pal.icon,
|
pal.icon,
|
||||||
pal.textLight,
|
pal.textLight,
|
||||||
_,
|
_,
|
||||||
preferences?.feeds?.saved?.length,
|
|
||||||
query,
|
query,
|
||||||
onChangeQuery,
|
onChangeQuery,
|
||||||
onPressCancelSearch,
|
onPressCancelSearch,
|
||||||
|
@ -585,16 +631,75 @@ export function FeedsScreen(_props: Props) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function SavedFeed({feedUri}: {feedUri: string}) {
|
function FeedOrFollowing({
|
||||||
|
savedFeedConfig: feed,
|
||||||
|
}: {
|
||||||
|
savedFeedConfig: AppBskyActorDefs.SavedFeed
|
||||||
|
}) {
|
||||||
|
return feed.type === 'timeline' ? (
|
||||||
|
<FollowingFeed />
|
||||||
|
) : (
|
||||||
|
<SavedFeed savedFeedConfig={feed} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FollowingFeed() {
|
||||||
|
const pal = usePalette('default')
|
||||||
|
const t = useTheme()
|
||||||
|
const {isMobile} = useWebMediaQueries()
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
testID={`saved-feed-timeline`}
|
||||||
|
style={[
|
||||||
|
pal.border,
|
||||||
|
styles.savedFeed,
|
||||||
|
isMobile && styles.savedFeedMobile,
|
||||||
|
]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.align_center,
|
||||||
|
a.justify_center,
|
||||||
|
{
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
borderRadius: 3,
|
||||||
|
backgroundColor: t.palette.primary_500,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<FilterTimeline
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
fill={t.palette.white}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={{flex: 1, flexDirection: 'row', gap: 8, alignItems: 'center'}}>
|
||||||
|
<Text type="lg-medium" style={pal.text} numberOfLines={1}>
|
||||||
|
<Trans>Following</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SavedFeed({
|
||||||
|
savedFeedConfig: feed,
|
||||||
|
}: {
|
||||||
|
savedFeedConfig: AppBskyActorDefs.SavedFeed
|
||||||
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {isMobile} = useWebMediaQueries()
|
const {isMobile} = useWebMediaQueries()
|
||||||
const {data: info, error} = useFeedSourceInfoQuery({uri: feedUri})
|
const {data: info, error} = useFeedSourceInfoQuery({uri: feed.value})
|
||||||
const typeAvatar = getAvatarTypeFromUri(feedUri)
|
const typeAvatar = getAvatarTypeFromUri(feed.value)
|
||||||
|
|
||||||
if (!info)
|
if (!info)
|
||||||
return (
|
return (
|
||||||
<SavedFeedLoadingPlaceholder
|
<SavedFeedLoadingPlaceholder
|
||||||
key={`savedFeedLoadingPlaceholder:${feedUri}`}
|
key={`savedFeedLoadingPlaceholder:${feed.value}`}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -632,6 +737,7 @@ function SavedFeed({feedUri}: {feedUri: string}) {
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{isMobile && (
|
{isMobile && (
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="chevron-right"
|
icon="chevron-right"
|
||||||
|
|
|
@ -8,8 +8,8 @@ import {useSetTitle} from '#/lib/hooks/useSetTitle'
|
||||||
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries'
|
||||||
import {logEvent, LogEvents, useGate} from '#/lib/statsig/statsig'
|
import {logEvent, LogEvents, useGate} from '#/lib/statsig/statsig'
|
||||||
import {emitSoftReset} from '#/state/events'
|
import {emitSoftReset} from '#/state/events'
|
||||||
import {FeedSourceInfo, usePinnedFeedsInfos} from '#/state/queries/feed'
|
import {SavedFeedSourceInfo, usePinnedFeedsInfos} from '#/state/queries/feed'
|
||||||
import {FeedDescriptor, FeedParams} from '#/state/queries/post-feed'
|
import {FeedParams} from '#/state/queries/post-feed'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
|
@ -26,6 +26,7 @@ import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager'
|
||||||
import {CustomFeedEmptyState} from 'view/com/posts/CustomFeedEmptyState'
|
import {CustomFeedEmptyState} from 'view/com/posts/CustomFeedEmptyState'
|
||||||
import {FollowingEmptyState} from 'view/com/posts/FollowingEmptyState'
|
import {FollowingEmptyState} from 'view/com/posts/FollowingEmptyState'
|
||||||
import {FollowingEndOfFeed} from 'view/com/posts/FollowingEndOfFeed'
|
import {FollowingEndOfFeed} from 'view/com/posts/FollowingEndOfFeed'
|
||||||
|
import {NoFeedsPinned} from '#/screens/Home/NoFeedsPinned'
|
||||||
import {HomeHeader} from '../com/home/HomeHeader'
|
import {HomeHeader} from '../com/home/HomeHeader'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
type Props = NativeStackScreenProps<HomeTabNavigatorParams, 'Home'>
|
||||||
|
@ -55,26 +56,16 @@ function HomeScreenReady({
|
||||||
pinnedFeedInfos,
|
pinnedFeedInfos,
|
||||||
}: Props & {
|
}: Props & {
|
||||||
preferences: UsePreferencesQueryResponse
|
preferences: UsePreferencesQueryResponse
|
||||||
pinnedFeedInfos: FeedSourceInfo[]
|
pinnedFeedInfos: SavedFeedSourceInfo[]
|
||||||
}) {
|
}) {
|
||||||
useOTAUpdates()
|
useOTAUpdates()
|
||||||
|
const allFeeds = React.useMemo(
|
||||||
const allFeeds = React.useMemo(() => {
|
() => pinnedFeedInfos.map(f => f.feedDescriptor),
|
||||||
const feeds: FeedDescriptor[] = []
|
[pinnedFeedInfos],
|
||||||
feeds.push('home')
|
)
|
||||||
for (const {uri} of pinnedFeedInfos) {
|
const rawSelectedFeed = useSelectedFeed() ?? allFeeds[0]
|
||||||
if (uri.includes('app.bsky.feed.generator')) {
|
|
||||||
feeds.push(`feedgen|${uri}`)
|
|
||||||
} else if (uri.includes('app.bsky.graph.list')) {
|
|
||||||
feeds.push(`list|${uri}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return feeds
|
|
||||||
}, [pinnedFeedInfos])
|
|
||||||
|
|
||||||
const rawSelectedFeed = useSelectedFeed()
|
|
||||||
const setSelectedFeed = useSetSelectedFeed()
|
const setSelectedFeed = useSetSelectedFeed()
|
||||||
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed as FeedDescriptor)
|
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed)
|
||||||
const selectedIndex = Math.max(0, maybeFoundIndex)
|
const selectedIndex = Math.max(0, maybeFoundIndex)
|
||||||
const selectedFeed = allFeeds[selectedIndex]
|
const selectedFeed = allFeeds[selectedIndex]
|
||||||
|
|
||||||
|
@ -107,12 +98,14 @@ function HomeScreenReady({
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useNonReactiveCallback(() => {
|
useNonReactiveCallback(() => {
|
||||||
logEvent('home:feedDisplayed', {
|
if (selectedFeed) {
|
||||||
index: selectedIndex,
|
logEvent('home:feedDisplayed', {
|
||||||
feedType: selectedFeed.split('|')[0],
|
index: selectedIndex,
|
||||||
feedUrl: selectedFeed,
|
feedType: selectedFeed.split('|')[0],
|
||||||
reason: 'focus',
|
feedUrl: selectedFeed,
|
||||||
})
|
reason: 'focus',
|
||||||
|
})
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -198,12 +191,13 @@ function HomeScreenReady({
|
||||||
return <CustomFeedEmptyState />
|
return <CustomFeedEmptyState />
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [homeFeed, ...customFeeds] = allFeeds
|
|
||||||
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
const homeFeedParams = React.useMemo<FeedParams>(() => {
|
||||||
return {
|
return {
|
||||||
mergeFeedEnabled: Boolean(preferences.feedViewPrefs.lab_mergeFeedEnabled),
|
mergeFeedEnabled: Boolean(preferences.feedViewPrefs.lab_mergeFeedEnabled),
|
||||||
mergeFeedSources: preferences.feedViewPrefs.lab_mergeFeedEnabled
|
mergeFeedSources: preferences.feedViewPrefs.lab_mergeFeedEnabled
|
||||||
? preferences.feeds.saved
|
? preferences.savedFeeds
|
||||||
|
.filter(f => f.type === 'feed' || f.type === 'list')
|
||||||
|
.map(f => f.value)
|
||||||
: [],
|
: [],
|
||||||
}
|
}
|
||||||
}, [preferences])
|
}, [preferences])
|
||||||
|
@ -218,26 +212,37 @@ function HomeScreenReady({
|
||||||
onPageSelected={onPageSelected}
|
onPageSelected={onPageSelected}
|
||||||
onPageScrollStateChanged={onPageScrollStateChanged}
|
onPageScrollStateChanged={onPageScrollStateChanged}
|
||||||
renderTabBar={renderTabBar}>
|
renderTabBar={renderTabBar}>
|
||||||
<FeedPage
|
{pinnedFeedInfos.length ? (
|
||||||
key={homeFeed}
|
pinnedFeedInfos.map(feedInfo => {
|
||||||
testID="followingFeedPage"
|
const feed = feedInfo.feedDescriptor
|
||||||
isPageFocused={selectedFeed === homeFeed}
|
if (feed === 'following') {
|
||||||
feed={homeFeed}
|
return (
|
||||||
feedParams={homeFeedParams}
|
<FeedPage
|
||||||
renderEmptyState={renderFollowingEmptyState}
|
key={feed}
|
||||||
renderEndOfFeed={FollowingEndOfFeed}
|
testID="followingFeedPage"
|
||||||
/>
|
isPageFocused={selectedFeed === feed}
|
||||||
{customFeeds.map(feed => {
|
feed={feed}
|
||||||
return (
|
feedParams={homeFeedParams}
|
||||||
<FeedPage
|
renderEmptyState={renderFollowingEmptyState}
|
||||||
key={feed}
|
renderEndOfFeed={FollowingEndOfFeed}
|
||||||
testID="customFeedPage"
|
/>
|
||||||
isPageFocused={selectedFeed === feed}
|
)
|
||||||
feed={feed}
|
}
|
||||||
renderEmptyState={renderCustomFeedEmptyState}
|
const savedFeedConfig = feedInfo.savedFeed
|
||||||
/>
|
return (
|
||||||
)
|
<FeedPage
|
||||||
})}
|
key={feed}
|
||||||
|
testID="customFeedPage"
|
||||||
|
isPageFocused={selectedFeed === feed}
|
||||||
|
feed={feed}
|
||||||
|
renderEmptyState={renderCustomFeedEmptyState}
|
||||||
|
savedFeedConfig={savedFeedConfig}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<NoFeedsPinned preferences={preferences} />
|
||||||
|
)}
|
||||||
</Pager>
|
</Pager>
|
||||||
) : (
|
) : (
|
||||||
<Pager
|
<Pager
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
import React, {useState} from 'react'
|
import React, {useState} from 'react'
|
||||||
import {ScrollView, StyleSheet, TouchableOpacity, View} from 'react-native'
|
import {ScrollView, StyleSheet, TouchableOpacity, View} from 'react-native'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {Slider} from '@miblanchard/react-native-slider'
|
import {msg, Plural, Trans} from '@lingui/macro'
|
||||||
import {Text} from '../com/util/text/Text'
|
|
||||||
import {s, colors} from 'lib/styles'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
|
||||||
import {isWeb} from 'platform/detection'
|
|
||||||
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
|
||||||
import {CommonNavigatorParams, NativeStackScreenProps} from 'lib/routes/types'
|
|
||||||
import {ViewHeader} from 'view/com/util/ViewHeader'
|
|
||||||
import {CenteredView} from 'view/com/util/Views'
|
|
||||||
import debounce from 'lodash.debounce'
|
|
||||||
import {Trans, msg, Plural} from '@lingui/macro'
|
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
import {Slider} from '@miblanchard/react-native-slider'
|
||||||
|
import debounce from 'lodash.debounce'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
useSetFeedViewPreferencesMutation,
|
useSetFeedViewPreferencesMutation,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
|
import {CommonNavigatorParams, NativeStackScreenProps} from 'lib/routes/types'
|
||||||
|
import {colors, s} from 'lib/styles'
|
||||||
|
import {isWeb} from 'platform/detection'
|
||||||
|
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
||||||
|
import {ViewHeader} from 'view/com/util/ViewHeader'
|
||||||
|
import {CenteredView} from 'view/com/util/Views'
|
||||||
|
import {Text} from '../com/util/text/Text'
|
||||||
|
|
||||||
function RepliesThresholdInput({
|
function RepliesThresholdInput({
|
||||||
enabled,
|
enabled,
|
||||||
|
|
|
@ -16,12 +16,11 @@ 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 {
|
||||||
usePinFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
useRemoveFeedMutation,
|
useRemoveFeedMutation,
|
||||||
useSaveFeedMutation,
|
useUpdateSavedFeedsMutation,
|
||||||
useUnpinFeedMutation,
|
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
|
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
|
||||||
import {truncateAndInvalidate} from '#/state/queries/util'
|
import {truncateAndInvalidate} from '#/state/queries/util'
|
||||||
|
@ -163,37 +162,20 @@ export function ProfileFeedScreenInner({
|
||||||
const feedSectionRef = React.useRef<SectionRef>(null)
|
const feedSectionRef = React.useRef<SectionRef>(null)
|
||||||
const isScreenFocused = useIsFocused()
|
const isScreenFocused = useIsFocused()
|
||||||
|
|
||||||
const {
|
const {mutateAsync: addSavedFeeds, isPending: isAddSavedFeedPending} =
|
||||||
mutateAsync: saveFeed,
|
useAddSavedFeedsMutation()
|
||||||
variables: savedFeed,
|
const {mutateAsync: removeFeed, isPending: isRemovePending} =
|
||||||
reset: resetSaveFeed,
|
useRemoveFeedMutation()
|
||||||
isPending: isSavePending,
|
const {mutateAsync: updateSavedFeeds, isPending: isUpdateFeedPending} =
|
||||||
} = useSaveFeedMutation()
|
useUpdateSavedFeedsMutation()
|
||||||
const {
|
|
||||||
mutateAsync: removeFeed,
|
|
||||||
variables: removedFeed,
|
|
||||||
reset: resetRemoveFeed,
|
|
||||||
isPending: isRemovePending,
|
|
||||||
} = useRemoveFeedMutation()
|
|
||||||
const {
|
|
||||||
mutateAsync: pinFeed,
|
|
||||||
variables: pinnedFeed,
|
|
||||||
reset: resetPinFeed,
|
|
||||||
isPending: isPinPending,
|
|
||||||
} = usePinFeedMutation()
|
|
||||||
const {
|
|
||||||
mutateAsync: unpinFeed,
|
|
||||||
variables: unpinnedFeed,
|
|
||||||
reset: resetUnpinFeed,
|
|
||||||
isPending: isUnpinPending,
|
|
||||||
} = useUnpinFeedMutation()
|
|
||||||
|
|
||||||
const isSaved =
|
const isPending =
|
||||||
!removedFeed &&
|
isAddSavedFeedPending || isRemovePending || isUpdateFeedPending
|
||||||
(!!savedFeed || preferences.feeds.saved.includes(feedInfo.uri))
|
const savedFeedConfig = preferences.savedFeeds.find(
|
||||||
const isPinned =
|
f => f.value === feedInfo.uri,
|
||||||
!unpinnedFeed &&
|
)
|
||||||
(!!pinnedFeed || preferences.feeds.pinned.includes(feedInfo.uri))
|
const isSaved = Boolean(savedFeedConfig)
|
||||||
|
const isPinned = Boolean(savedFeedConfig?.pinned)
|
||||||
|
|
||||||
useSetTitle(feedInfo?.displayName)
|
useSetTitle(feedInfo?.displayName)
|
||||||
|
|
||||||
|
@ -204,13 +186,17 @@ export function ProfileFeedScreenInner({
|
||||||
try {
|
try {
|
||||||
playHaptic()
|
playHaptic()
|
||||||
|
|
||||||
if (isSaved) {
|
if (savedFeedConfig) {
|
||||||
await removeFeed({uri: feedInfo.uri})
|
await removeFeed(savedFeedConfig)
|
||||||
resetRemoveFeed()
|
|
||||||
Toast.show(_(msg`Removed from your feeds`))
|
Toast.show(_(msg`Removed from your feeds`))
|
||||||
} else {
|
} else {
|
||||||
await saveFeed({uri: feedInfo.uri})
|
await addSavedFeeds([
|
||||||
resetSaveFeed()
|
{
|
||||||
|
type: 'feed',
|
||||||
|
value: feedInfo.uri,
|
||||||
|
pinned: false,
|
||||||
|
},
|
||||||
|
])
|
||||||
Toast.show(_(msg`Saved to your feeds`))
|
Toast.show(_(msg`Saved to your feeds`))
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -221,27 +207,27 @@ export function ProfileFeedScreenInner({
|
||||||
)
|
)
|
||||||
logger.error('Failed up update feeds', {message: err})
|
logger.error('Failed up update feeds', {message: err})
|
||||||
}
|
}
|
||||||
}, [
|
}, [_, playHaptic, feedInfo, removeFeed, addSavedFeeds, savedFeedConfig])
|
||||||
playHaptic,
|
|
||||||
isSaved,
|
|
||||||
removeFeed,
|
|
||||||
feedInfo,
|
|
||||||
resetRemoveFeed,
|
|
||||||
_,
|
|
||||||
saveFeed,
|
|
||||||
resetSaveFeed,
|
|
||||||
])
|
|
||||||
|
|
||||||
const onTogglePinned = React.useCallback(async () => {
|
const onTogglePinned = React.useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
playHaptic()
|
playHaptic()
|
||||||
|
|
||||||
if (isPinned) {
|
if (savedFeedConfig) {
|
||||||
await unpinFeed({uri: feedInfo.uri})
|
await updateSavedFeeds([
|
||||||
resetUnpinFeed()
|
{
|
||||||
|
...savedFeedConfig,
|
||||||
|
pinned: !savedFeedConfig.pinned,
|
||||||
|
},
|
||||||
|
])
|
||||||
} else {
|
} else {
|
||||||
await pinFeed({uri: feedInfo.uri})
|
await addSavedFeeds([
|
||||||
resetPinFeed()
|
{
|
||||||
|
type: 'feed',
|
||||||
|
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`))
|
||||||
|
@ -249,13 +235,11 @@ export function ProfileFeedScreenInner({
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
playHaptic,
|
playHaptic,
|
||||||
isPinned,
|
|
||||||
unpinFeed,
|
|
||||||
feedInfo,
|
feedInfo,
|
||||||
resetUnpinFeed,
|
|
||||||
pinFeed,
|
|
||||||
resetPinFeed,
|
|
||||||
_,
|
_,
|
||||||
|
savedFeedConfig,
|
||||||
|
updateSavedFeeds,
|
||||||
|
addSavedFeeds,
|
||||||
])
|
])
|
||||||
|
|
||||||
const onPressShare = React.useCallback(() => {
|
const onPressShare = React.useCallback(() => {
|
||||||
|
@ -296,7 +280,7 @@ export function ProfileFeedScreenInner({
|
||||||
{feedInfo && hasSession && (
|
{feedInfo && hasSession && (
|
||||||
<NewButton
|
<NewButton
|
||||||
testID={isPinned ? 'unpinBtn' : 'pinBtn'}
|
testID={isPinned ? 'unpinBtn' : 'pinBtn'}
|
||||||
disabled={isPinPending || isUnpinPending}
|
disabled={isPending}
|
||||||
size="small"
|
size="small"
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color={isPinned ? 'secondary' : 'primary'}
|
color={isPinned ? 'secondary' : 'primary'}
|
||||||
|
@ -339,7 +323,7 @@ export function ProfileFeedScreenInner({
|
||||||
{hasSession && (
|
{hasSession && (
|
||||||
<>
|
<>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
disabled={isSavePending || isRemovePending}
|
disabled={isPending}
|
||||||
testID="feedHeaderDropdownToggleSavedBtn"
|
testID="feedHeaderDropdownToggleSavedBtn"
|
||||||
label={
|
label={
|
||||||
isSaved
|
isSaved
|
||||||
|
@ -395,14 +379,11 @@ export function ProfileFeedScreenInner({
|
||||||
onTogglePinned,
|
onTogglePinned,
|
||||||
onToggleSaved,
|
onToggleSaved,
|
||||||
currentAccount?.did,
|
currentAccount?.did,
|
||||||
isPinPending,
|
|
||||||
isRemovePending,
|
|
||||||
isSavePending,
|
|
||||||
isSaved,
|
isSaved,
|
||||||
isUnpinPending,
|
|
||||||
onPressReport,
|
onPressReport,
|
||||||
onPressShare,
|
onPressShare,
|
||||||
t,
|
t,
|
||||||
|
isPending,
|
||||||
])
|
])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -23,10 +23,10 @@ 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 {
|
||||||
usePinFeedMutation,
|
useAddSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
useSetSaveFeedsMutation,
|
useRemoveFeedMutation,
|
||||||
useUnpinFeedMutation,
|
useUpdateSavedFeedsMutation,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
|
import {useResolveUriQuery} from '#/state/queries/resolve-uri'
|
||||||
import {truncateAndInvalidate} from '#/state/queries/util'
|
import {truncateAndInvalidate} from '#/state/queries/util'
|
||||||
|
@ -248,36 +248,76 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
const isBlocking = !!list.viewer?.blocked
|
const isBlocking = !!list.viewer?.blocked
|
||||||
const isMuting = !!list.viewer?.muted
|
const isMuting = !!list.viewer?.muted
|
||||||
const isOwner = list.creator.did === currentAccount?.did
|
const isOwner = list.creator.did === currentAccount?.did
|
||||||
const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation()
|
|
||||||
const {isPending: isUnpinPending, mutateAsync: unpinFeed} =
|
|
||||||
useUnpinFeedMutation()
|
|
||||||
const isPending = isPinPending || isUnpinPending
|
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const {mutate: setSavedFeeds} = useSetSaveFeedsMutation()
|
|
||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
|
|
||||||
|
const {mutateAsync: addSavedFeeds, isPending: isAddSavedFeedPending} =
|
||||||
|
useAddSavedFeedsMutation()
|
||||||
|
const {mutateAsync: removeSavedFeed, isPending: isRemovePending} =
|
||||||
|
useRemoveFeedMutation()
|
||||||
|
const {mutateAsync: updateSavedFeeds, isPending: isUpdatingSavedFeeds} =
|
||||||
|
useUpdateSavedFeedsMutation()
|
||||||
|
|
||||||
|
const isPending =
|
||||||
|
isAddSavedFeedPending || isRemovePending || isUpdatingSavedFeeds
|
||||||
|
|
||||||
const deleteListPromptControl = useDialogControl()
|
const deleteListPromptControl = useDialogControl()
|
||||||
const subscribeMutePromptControl = useDialogControl()
|
const subscribeMutePromptControl = useDialogControl()
|
||||||
const subscribeBlockPromptControl = useDialogControl()
|
const subscribeBlockPromptControl = useDialogControl()
|
||||||
|
|
||||||
const isPinned = preferences?.feeds?.pinned?.includes(list.uri)
|
const savedFeedConfig = preferences?.savedFeeds?.find(
|
||||||
const isSaved = preferences?.feeds?.saved?.includes(list.uri)
|
f => f.value === list.uri,
|
||||||
|
)
|
||||||
|
const isPinned = Boolean(savedFeedConfig?.pinned)
|
||||||
|
|
||||||
const onTogglePinned = React.useCallback(async () => {
|
const onTogglePinned = React.useCallback(async () => {
|
||||||
playHaptic()
|
playHaptic()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isPinned) {
|
if (savedFeedConfig) {
|
||||||
await unpinFeed({uri: list.uri})
|
const pinned = !savedFeedConfig.pinned
|
||||||
|
await updateSavedFeeds([
|
||||||
|
{
|
||||||
|
...savedFeedConfig,
|
||||||
|
pinned,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
Toast.show(_(msg`${pinned ? 'Pinned to' : 'Unpinned from'} your feeds`))
|
||||||
} else {
|
} else {
|
||||||
await pinFeed({uri: list.uri})
|
await addSavedFeeds([
|
||||||
|
{
|
||||||
|
type: 'list',
|
||||||
|
value: list.uri,
|
||||||
|
pinned: true,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
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, isPinned, unpinFeed, list.uri, pinFeed, _])
|
}, [
|
||||||
|
playHaptic,
|
||||||
|
addSavedFeeds,
|
||||||
|
updateSavedFeeds,
|
||||||
|
list.uri,
|
||||||
|
_,
|
||||||
|
savedFeedConfig,
|
||||||
|
])
|
||||||
|
|
||||||
|
const onRemoveFromSavedFeeds = React.useCallback(async () => {
|
||||||
|
playHaptic()
|
||||||
|
if (!savedFeedConfig) return
|
||||||
|
try {
|
||||||
|
await removeSavedFeed(savedFeedConfig)
|
||||||
|
Toast.show(_(msg`Removed from your feeds`))
|
||||||
|
} catch (e) {
|
||||||
|
Toast.show(_(msg`There was an issue contacting the server`))
|
||||||
|
logger.error('Failed to remove pinned list', {message: e})
|
||||||
|
}
|
||||||
|
}, [playHaptic, removeSavedFeed, _, savedFeedConfig])
|
||||||
|
|
||||||
const onSubscribeMute = useCallback(async () => {
|
const onSubscribeMute = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -345,13 +385,8 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
const onPressDelete = useCallback(async () => {
|
const onPressDelete = useCallback(async () => {
|
||||||
await listDeleteMutation.mutateAsync({uri: list.uri})
|
await listDeleteMutation.mutateAsync({uri: list.uri})
|
||||||
|
|
||||||
if (isSaved || isPinned) {
|
if (savedFeedConfig) {
|
||||||
const {saved, pinned} = preferences!.feeds
|
await removeSavedFeed(savedFeedConfig)
|
||||||
|
|
||||||
setSavedFeeds({
|
|
||||||
saved: isSaved ? saved.filter(uri => uri !== list.uri) : saved,
|
|
||||||
pinned: isPinned ? pinned.filter(uri => uri !== list.uri) : pinned,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast.show(_(msg`List deleted`))
|
Toast.show(_(msg`List deleted`))
|
||||||
|
@ -367,10 +402,8 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
navigation,
|
navigation,
|
||||||
track,
|
track,
|
||||||
_,
|
_,
|
||||||
preferences,
|
removeSavedFeed,
|
||||||
isPinned,
|
savedFeedConfig,
|
||||||
isSaved,
|
|
||||||
setSavedFeeds,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const onPressReport = useCallback(() => {
|
const onPressReport = useCallback(() => {
|
||||||
|
@ -398,6 +431,22 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (savedFeedConfig) {
|
||||||
|
items.push({
|
||||||
|
testID: 'listHeaderDropdownRemoveFromFeedsBtn',
|
||||||
|
label: _(msg`Remove from my feeds`),
|
||||||
|
onPress: onRemoveFromSavedFeeds,
|
||||||
|
icon: {
|
||||||
|
ios: {
|
||||||
|
name: 'trash',
|
||||||
|
},
|
||||||
|
android: '',
|
||||||
|
web: ['far', 'trash-can'],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (isOwner) {
|
if (isOwner) {
|
||||||
items.push({label: 'separator'})
|
items.push({label: 'separator'})
|
||||||
items.push({
|
items.push({
|
||||||
|
@ -444,7 +493,10 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
items.push({
|
items.push({
|
||||||
testID: 'listHeaderDropdownUnpinBtn',
|
testID: 'listHeaderDropdownUnpinBtn',
|
||||||
label: _(msg`Unpin moderation list`),
|
label: _(msg`Unpin moderation list`),
|
||||||
onPress: isPending ? undefined : () => unpinFeed({uri: list.uri}),
|
onPress:
|
||||||
|
isPending || !savedFeedConfig
|
||||||
|
? undefined
|
||||||
|
: () => removeSavedFeed(savedFeedConfig),
|
||||||
icon: {
|
icon: {
|
||||||
ios: {
|
ios: {
|
||||||
name: 'pin',
|
name: 'pin',
|
||||||
|
@ -499,12 +551,13 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) {
|
||||||
deleteListPromptControl.open,
|
deleteListPromptControl.open,
|
||||||
onPressReport,
|
onPressReport,
|
||||||
isPending,
|
isPending,
|
||||||
unpinFeed,
|
|
||||||
list.uri,
|
|
||||||
isBlocking,
|
isBlocking,
|
||||||
isMuting,
|
isMuting,
|
||||||
onUnsubscribeMute,
|
onUnsubscribeMute,
|
||||||
onUnsubscribeBlock,
|
onUnsubscribeBlock,
|
||||||
|
removeSavedFeed,
|
||||||
|
savedFeedConfig,
|
||||||
|
onRemoveFromSavedFeeds,
|
||||||
])
|
])
|
||||||
|
|
||||||
const subscribeDropdownItems: DropdownItem[] = useMemo(() => {
|
const subscribeDropdownItems: DropdownItem[] = useMemo(() => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {ActivityIndicator, Pressable, StyleSheet, View} from 'react-native'
|
import {ActivityIndicator, Pressable, StyleSheet, View} from 'react-native'
|
||||||
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
@ -9,11 +10,11 @@ import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||||
import {track} from '#/lib/analytics/analytics'
|
import {track} from '#/lib/analytics/analytics'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {
|
import {
|
||||||
usePinFeedMutation,
|
useOverwriteSavedFeedsMutation,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
useSetSaveFeedsMutation,
|
useUpdateSavedFeedsMutation,
|
||||||
useUnpinFeedMutation,
|
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
|
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
|
||||||
import {useSetMinimalShellMode} from '#/state/shell'
|
import {useSetMinimalShellMode} from '#/state/shell'
|
||||||
import {useAnalytics} from 'lib/analytics/analytics'
|
import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
import {useHaptics} from 'lib/haptics'
|
import {useHaptics} from 'lib/haptics'
|
||||||
|
@ -27,6 +28,10 @@ import {Text} from 'view/com/util/text/Text'
|
||||||
import * as Toast from 'view/com/util/Toast'
|
import * as Toast from 'view/com/util/Toast'
|
||||||
import {ViewHeader} from 'view/com/util/ViewHeader'
|
import {ViewHeader} from 'view/com/util/ViewHeader'
|
||||||
import {CenteredView, ScrollView} from 'view/com/util/Views'
|
import {CenteredView, ScrollView} from 'view/com/util/Views'
|
||||||
|
import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed'
|
||||||
|
import {NoSavedFeedsOfAnyType} from '#/screens/Feeds/NoSavedFeedsOfAnyType'
|
||||||
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
|
import {FilterTimeline_Stroke2_Corner0_Rounded as FilterTimeline} from '#/components/icons/FilterTimeline'
|
||||||
|
|
||||||
const HITSLOP_TOP = {
|
const HITSLOP_TOP = {
|
||||||
top: 20,
|
top: 20,
|
||||||
|
@ -50,23 +55,25 @@ export function SavedFeeds({}: Props) {
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const {
|
const {
|
||||||
mutateAsync: setSavedFeeds,
|
mutateAsync: overwriteSavedFeeds,
|
||||||
variables: optimisticSavedFeedsResponse,
|
variables: optimisticSavedFeedsResponse,
|
||||||
reset: resetSaveFeedsMutationState,
|
reset: resetSaveFeedsMutationState,
|
||||||
error: setSavedFeedsError,
|
error: savedFeedsError,
|
||||||
} = useSetSaveFeedsMutation()
|
} = useOverwriteSavedFeedsMutation()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use optimistic data if exists and no error, otherwise fallback to remote
|
* Use optimistic data if exists and no error, otherwise fallback to remote
|
||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
const currentFeeds =
|
const currentFeeds =
|
||||||
optimisticSavedFeedsResponse && !setSavedFeedsError
|
optimisticSavedFeedsResponse && !savedFeedsError
|
||||||
? optimisticSavedFeedsResponse
|
? optimisticSavedFeedsResponse
|
||||||
: preferences?.feeds || {saved: [], pinned: []}
|
: preferences?.savedFeeds || []
|
||||||
const unpinned = currentFeeds.saved.filter(f => {
|
const pinnedFeeds = currentFeeds.filter(f => f.pinned)
|
||||||
return !currentFeeds.pinned?.includes(f)
|
const unpinnedFeeds = currentFeeds.filter(f => !f.pinned)
|
||||||
})
|
const noSavedFeedsOfAnyType = pinnedFeeds.length + unpinnedFeeds.length === 0
|
||||||
|
const noFollowingFeed =
|
||||||
|
currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeedsOfAnyType
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
|
@ -84,14 +91,20 @@ export function SavedFeeds({}: Props) {
|
||||||
]}>
|
]}>
|
||||||
<ViewHeader title={_(msg`Edit My Feeds`)} showOnDesktop showBorder />
|
<ViewHeader title={_(msg`Edit My Feeds`)} showOnDesktop showBorder />
|
||||||
<ScrollView style={s.flex1} contentContainerStyle={[styles.noBorder]}>
|
<ScrollView style={s.flex1} contentContainerStyle={[styles.noBorder]}>
|
||||||
|
{noSavedFeedsOfAnyType && (
|
||||||
|
<View style={[pal.border, {borderBottomWidth: 1}]}>
|
||||||
|
<NoSavedFeedsOfAnyType />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
<View style={[pal.text, pal.border, styles.title]}>
|
<View style={[pal.text, pal.border, styles.title]}>
|
||||||
<Text type="title" style={pal.text}>
|
<Text type="title" style={pal.text}>
|
||||||
<Trans>Pinned Feeds</Trans>
|
<Trans>Pinned Feeds</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{preferences?.feeds ? (
|
{preferences ? (
|
||||||
!currentFeeds.pinned.length ? (
|
!pinnedFeeds.length ? (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
pal.border,
|
pal.border,
|
||||||
|
@ -104,27 +117,35 @@ export function SavedFeeds({}: Props) {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
currentFeeds.pinned.map(uri => (
|
pinnedFeeds.map(f => (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={uri}
|
key={f.id}
|
||||||
feedUri={uri}
|
feed={f}
|
||||||
isPinned
|
isPinned
|
||||||
setSavedFeeds={setSavedFeeds}
|
overwriteSavedFeeds={overwriteSavedFeeds}
|
||||||
resetSaveFeedsMutationState={resetSaveFeedsMutationState}
|
resetSaveFeedsMutationState={resetSaveFeedsMutationState}
|
||||||
currentFeeds={currentFeeds}
|
currentFeeds={currentFeeds}
|
||||||
|
preferences={preferences}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<ActivityIndicator style={{marginTop: 20}} />
|
<ActivityIndicator style={{marginTop: 20}} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{noFollowingFeed && (
|
||||||
|
<View style={[pal.border, {borderBottomWidth: 1}]}>
|
||||||
|
<NoFollowingFeed />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
<View style={[pal.text, pal.border, styles.title]}>
|
<View style={[pal.text, pal.border, styles.title]}>
|
||||||
<Text type="title" style={pal.text}>
|
<Text type="title" style={pal.text}>
|
||||||
<Trans>Saved Feeds</Trans>
|
<Trans>Saved Feeds</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
{preferences?.feeds ? (
|
{preferences ? (
|
||||||
!unpinned.length ? (
|
!unpinnedFeeds.length ? (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
pal.border,
|
pal.border,
|
||||||
|
@ -137,14 +158,15 @@ export function SavedFeeds({}: Props) {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
unpinned.map(uri => (
|
unpinnedFeeds.map(f => (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={uri}
|
key={f.id}
|
||||||
feedUri={uri}
|
feed={f}
|
||||||
isPinned={false}
|
isPinned={false}
|
||||||
setSavedFeeds={setSavedFeeds}
|
overwriteSavedFeeds={overwriteSavedFeeds}
|
||||||
resetSaveFeedsMutationState={resetSaveFeedsMutationState}
|
resetSaveFeedsMutationState={resetSaveFeedsMutationState}
|
||||||
currentFeeds={currentFeeds}
|
currentFeeds={currentFeeds}
|
||||||
|
preferences={preferences}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
|
@ -174,27 +196,29 @@ export function SavedFeeds({}: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListItem({
|
function ListItem({
|
||||||
feedUri,
|
feed,
|
||||||
isPinned,
|
isPinned,
|
||||||
currentFeeds,
|
currentFeeds,
|
||||||
setSavedFeeds,
|
overwriteSavedFeeds,
|
||||||
resetSaveFeedsMutationState,
|
resetSaveFeedsMutationState,
|
||||||
}: {
|
}: {
|
||||||
feedUri: string // uri
|
feed: AppBskyActorDefs.SavedFeed
|
||||||
isPinned: boolean
|
isPinned: boolean
|
||||||
currentFeeds: {saved: string[]; pinned: string[]}
|
currentFeeds: AppBskyActorDefs.SavedFeed[]
|
||||||
setSavedFeeds: ReturnType<typeof useSetSaveFeedsMutation>['mutateAsync']
|
overwriteSavedFeeds: ReturnType<
|
||||||
|
typeof useOverwriteSavedFeedsMutation
|
||||||
|
>['mutateAsync']
|
||||||
resetSaveFeedsMutationState: ReturnType<
|
resetSaveFeedsMutationState: ReturnType<
|
||||||
typeof useSetSaveFeedsMutation
|
typeof useOverwriteSavedFeedsMutation
|
||||||
>['reset']
|
>['reset']
|
||||||
|
preferences: UsePreferencesQueryResponse
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
const {isPending: isPinPending, mutateAsync: pinFeed} = usePinFeedMutation()
|
const {isPending: isUpdatePending, mutateAsync: updateSavedFeeds} =
|
||||||
const {isPending: isUnpinPending, mutateAsync: unpinFeed} =
|
useUpdateSavedFeedsMutation()
|
||||||
useUnpinFeedMutation()
|
const feedUri = feed.value
|
||||||
const isPending = isPinPending || isUnpinPending
|
|
||||||
|
|
||||||
const onTogglePinned = React.useCallback(async () => {
|
const onTogglePinned = React.useCallback(async () => {
|
||||||
playHaptic()
|
playHaptic()
|
||||||
|
@ -202,81 +226,82 @@ function ListItem({
|
||||||
try {
|
try {
|
||||||
resetSaveFeedsMutationState()
|
resetSaveFeedsMutationState()
|
||||||
|
|
||||||
if (isPinned) {
|
await updateSavedFeeds([
|
||||||
await unpinFeed({uri: feedUri})
|
{
|
||||||
} else {
|
...feed,
|
||||||
await pinFeed({uri: feedUri})
|
pinned: !feed.pinned,
|
||||||
}
|
},
|
||||||
|
])
|
||||||
} 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, feed, updateSavedFeeds, resetSaveFeedsMutationState])
|
||||||
playHaptic,
|
|
||||||
resetSaveFeedsMutationState,
|
|
||||||
isPinned,
|
|
||||||
unpinFeed,
|
|
||||||
feedUri,
|
|
||||||
pinFeed,
|
|
||||||
_,
|
|
||||||
])
|
|
||||||
|
|
||||||
const onPressUp = React.useCallback(async () => {
|
const onPressUp = React.useCallback(async () => {
|
||||||
if (!isPinned) return
|
if (!isPinned) return
|
||||||
|
|
||||||
// create new array, do not mutate
|
const nextFeeds = currentFeeds.slice()
|
||||||
const pinned = [...currentFeeds.pinned]
|
const ids = currentFeeds.map(f => f.id)
|
||||||
const index = pinned.indexOf(feedUri)
|
const index = ids.indexOf(feed.id)
|
||||||
|
const nextIndex = index - 1
|
||||||
|
|
||||||
if (index === -1 || index === 0) return
|
if (index === -1 || index === 0) return
|
||||||
;[pinned[index], pinned[index - 1]] = [pinned[index - 1], pinned[index]]
|
;[nextFeeds[index], nextFeeds[nextIndex]] = [
|
||||||
|
nextFeeds[nextIndex],
|
||||||
|
nextFeeds[index],
|
||||||
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setSavedFeeds({saved: currentFeeds.saved, pinned})
|
await overwriteSavedFeeds(nextFeeds)
|
||||||
track('CustomFeed:Reorder', {
|
track('CustomFeed:Reorder', {
|
||||||
uri: feedUri,
|
uri: feed.value,
|
||||||
index: pinned.indexOf(feedUri),
|
index: nextIndex,
|
||||||
})
|
})
|
||||||
} 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 set pinned feed order', {message: e})
|
logger.error('Failed to set pinned feed order', {message: e})
|
||||||
}
|
}
|
||||||
}, [feedUri, isPinned, setSavedFeeds, currentFeeds, _])
|
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])
|
||||||
|
|
||||||
const onPressDown = React.useCallback(async () => {
|
const onPressDown = React.useCallback(async () => {
|
||||||
if (!isPinned) return
|
if (!isPinned) return
|
||||||
|
|
||||||
const pinned = [...currentFeeds.pinned]
|
const nextFeeds = currentFeeds.slice()
|
||||||
const index = pinned.indexOf(feedUri)
|
const ids = currentFeeds.map(f => f.id)
|
||||||
|
const index = ids.indexOf(feed.id)
|
||||||
|
const nextIndex = index + 1
|
||||||
|
|
||||||
if (index === -1 || index >= pinned.length - 1) return
|
if (index === -1 || index >= nextFeeds.length - 1) return
|
||||||
;[pinned[index], pinned[index + 1]] = [pinned[index + 1], pinned[index]]
|
;[nextFeeds[index], nextFeeds[nextIndex]] = [
|
||||||
|
nextFeeds[nextIndex],
|
||||||
|
nextFeeds[index],
|
||||||
|
]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await setSavedFeeds({saved: currentFeeds.saved, pinned})
|
await overwriteSavedFeeds(nextFeeds)
|
||||||
track('CustomFeed:Reorder', {
|
track('CustomFeed:Reorder', {
|
||||||
uri: feedUri,
|
uri: feed.value,
|
||||||
index: pinned.indexOf(feedUri),
|
index: nextIndex,
|
||||||
})
|
})
|
||||||
} 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 set pinned feed order', {message: e})
|
logger.error('Failed to set pinned feed order', {message: e})
|
||||||
}
|
}
|
||||||
}, [feedUri, isPinned, setSavedFeeds, currentFeeds, _])
|
}, [feed, isPinned, overwriteSavedFeeds, currentFeeds, _])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pressable
|
<View style={[styles.itemContainer, pal.border]}>
|
||||||
accessibilityRole="button"
|
|
||||||
style={[styles.itemContainer, pal.border]}>
|
|
||||||
{isPinned ? (
|
{isPinned ? (
|
||||||
<View style={styles.webArrowButtonsContainer}>
|
<View style={styles.webArrowButtonsContainer}>
|
||||||
<Pressable
|
<Pressable
|
||||||
disabled={isPending}
|
disabled={isUpdatePending}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
onPress={onPressUp}
|
onPress={onPressUp}
|
||||||
hitSlop={HITSLOP_TOP}
|
hitSlop={HITSLOP_TOP}
|
||||||
style={state => ({
|
style={state => ({
|
||||||
opacity: state.hovered || state.focused || isPending ? 0.5 : 1,
|
opacity:
|
||||||
|
state.hovered || state.focused || isUpdatePending ? 0.5 : 1,
|
||||||
})}>
|
})}>
|
||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon="arrow-up"
|
icon="arrow-up"
|
||||||
|
@ -285,39 +310,92 @@ function ListItem({
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
</Pressable>
|
||||||
<Pressable
|
<Pressable
|
||||||
disabled={isPending}
|
disabled={isUpdatePending}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
onPress={onPressDown}
|
onPress={onPressDown}
|
||||||
hitSlop={HITSLOP_BOTTOM}
|
hitSlop={HITSLOP_BOTTOM}
|
||||||
style={state => ({
|
style={state => ({
|
||||||
opacity: state.hovered || state.focused || isPending ? 0.5 : 1,
|
opacity:
|
||||||
|
state.hovered || state.focused || isUpdatePending ? 0.5 : 1,
|
||||||
})}>
|
})}>
|
||||||
<FontAwesomeIcon icon="arrow-down" size={12} style={[pal.text]} />
|
<FontAwesomeIcon icon="arrow-down" size={12} style={[pal.text]} />
|
||||||
</Pressable>
|
</Pressable>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
<FeedSourceCard
|
{feed.type === 'timeline' ? (
|
||||||
key={feedUri}
|
<FollowingFeedCard />
|
||||||
feedUri={feedUri}
|
) : (
|
||||||
style={styles.noTopBorder}
|
<FeedSourceCard
|
||||||
showSaveBtn
|
key={feedUri}
|
||||||
showMinimalPlaceholder
|
feedUri={feedUri}
|
||||||
/>
|
style={styles.noTopBorder}
|
||||||
<Pressable
|
showSaveBtn
|
||||||
disabled={isPending}
|
showMinimalPlaceholder
|
||||||
accessibilityRole="button"
|
|
||||||
hitSlop={10}
|
|
||||||
onPress={onTogglePinned}
|
|
||||||
style={state => ({
|
|
||||||
opacity: state.hovered || state.focused || isPending ? 0.5 : 1,
|
|
||||||
})}>
|
|
||||||
<FontAwesomeIcon
|
|
||||||
icon="thumb-tack"
|
|
||||||
size={20}
|
|
||||||
color={isPinned ? colors.blue3 : pal.colors.icon}
|
|
||||||
/>
|
/>
|
||||||
</Pressable>
|
)}
|
||||||
</Pressable>
|
<View style={{paddingRight: 16}}>
|
||||||
|
<Pressable
|
||||||
|
disabled={isUpdatePending}
|
||||||
|
accessibilityRole="button"
|
||||||
|
hitSlop={10}
|
||||||
|
onPress={onTogglePinned}
|
||||||
|
style={state => ({
|
||||||
|
opacity:
|
||||||
|
state.hovered || state.focused || isUpdatePending ? 0.5 : 1,
|
||||||
|
})}>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon="thumb-tack"
|
||||||
|
size={20}
|
||||||
|
color={isPinned ? colors.blue3 : pal.colors.icon}
|
||||||
|
/>
|
||||||
|
</Pressable>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function FollowingFeedCard() {
|
||||||
|
const t = useTheme()
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.flex_row,
|
||||||
|
a.align_center,
|
||||||
|
a.flex_1,
|
||||||
|
{
|
||||||
|
paddingHorizontal: 18,
|
||||||
|
paddingVertical: 20,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
a.align_center,
|
||||||
|
a.justify_center,
|
||||||
|
a.rounded_sm,
|
||||||
|
{
|
||||||
|
width: 36,
|
||||||
|
height: 36,
|
||||||
|
backgroundColor: t.palette.primary_500,
|
||||||
|
marginRight: 10,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<FilterTimeline
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
width: 22,
|
||||||
|
height: 22,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
fill={t.palette.white}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View
|
||||||
|
style={{flex: 1, flexDirection: 'row', gap: 8, alignItems: 'center'}}>
|
||||||
|
<Text type="lg-medium" style={[t.atoms.text]} numberOfLines={1}>
|
||||||
|
<Trans>Following</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +423,6 @@ const styles = StyleSheet.create({
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
borderBottomWidth: 1,
|
borderBottomWidth: 1,
|
||||||
paddingRight: 16,
|
|
||||||
},
|
},
|
||||||
webArrowButtonsContainer: {
|
webArrowButtonsContainer: {
|
||||||
paddingLeft: 16,
|
paddingLeft: 16,
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {View, StyleSheet} from 'react-native'
|
import {StyleSheet, View} from 'react-native'
|
||||||
import {useNavigationState, useNavigation} from '@react-navigation/native'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
import {TextLink} from 'view/com/util/Link'
|
|
||||||
import {getCurrentRoute} from 'lib/routes/helpers'
|
|
||||||
import {useLingui} from '@lingui/react'
|
|
||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
import {useNavigation, useNavigationState} from '@react-navigation/native'
|
||||||
|
|
||||||
|
import {emitSoftReset} from '#/state/events'
|
||||||
import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
import {usePinnedFeedsInfos} from '#/state/queries/feed'
|
||||||
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
|
import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed'
|
||||||
import {FeedDescriptor} from '#/state/queries/post-feed'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
|
import {getCurrentRoute} from 'lib/routes/helpers'
|
||||||
import {NavigationProp} from 'lib/routes/types'
|
import {NavigationProp} from 'lib/routes/types'
|
||||||
import {emitSoftReset} from '#/state/events'
|
import {TextLink} from 'view/com/util/Link'
|
||||||
|
|
||||||
export function DesktopFeeds() {
|
export function DesktopFeeds() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
|
@ -31,17 +31,7 @@ export function DesktopFeeds() {
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, pal.view]}>
|
<View style={[styles.container, pal.view]}>
|
||||||
{pinnedFeedInfos.map(feedInfo => {
|
{pinnedFeedInfos.map(feedInfo => {
|
||||||
const uri = feedInfo.uri
|
const feed = feedInfo.feedDescriptor
|
||||||
let feed: FeedDescriptor
|
|
||||||
if (!uri) {
|
|
||||||
feed = 'home'
|
|
||||||
} else if (uri.includes('app.bsky.feed.generator')) {
|
|
||||||
feed = `feedgen|${uri}`
|
|
||||||
} else if (uri.includes('app.bsky.graph.list')) {
|
|
||||||
feed = `list|${uri}`
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<FeedItem
|
<FeedItem
|
||||||
key={feed}
|
key={feed}
|
||||||
|
|
|
@ -58,10 +58,10 @@
|
||||||
multiformats "^9.9.0"
|
multiformats "^9.9.0"
|
||||||
tlds "^1.234.0"
|
tlds "^1.234.0"
|
||||||
|
|
||||||
"@atproto/api@^0.12.5":
|
"@atproto/api@^0.12.6":
|
||||||
version "0.12.5"
|
version "0.12.6"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.12.5.tgz#3ed70990b27c468d9663ca71306039cab663ca96"
|
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.12.6.tgz#690c004c5ac7fc7bceac4605d8c1ec1f580be270"
|
||||||
integrity sha512-xqdl/KrAK2kW6hN8+eSmKTWHgMNaPnDAEvZzo08Xbk/5jdRzjoEPS+p7k/wQ+ZefwOHL3QUbVPO4hMfmVxzO/Q==
|
integrity sha512-30htXN2Hjl1jzzeAtIhggOsVS4vA975pMUQYoA4xMonug+z6O9NHcka3yYb4C9ldpnGugvRPKH7EhAUbiDTC5w==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/common-web" "^0.3.0"
|
"@atproto/common-web" "^0.3.0"
|
||||||
"@atproto/lexicon" "^0.4.0"
|
"@atproto/lexicon" "^0.4.0"
|
||||||
|
|
Loading…
Reference in New Issue