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

Configure Feed

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

at a876aae44ea07494ebea9727350aa060b81f317b 147 lines 4.6 kB view raw
1import {useCallback} from 'react' 2import {View} from 'react-native' 3import {msg} from '@lingui/core/macro' 4import {useLingui} from '@lingui/react' 5import {Trans} from '@lingui/react/macro' 6 7import {PROD_DEFAULT_FEED} from '#/lib/constants' 8import {logger} from '#/logger' 9import { 10 usePreferencesQuery, 11 useRemoveFeedMutation, 12 useReplaceForYouWithDiscoverFeedMutation, 13} from '#/state/queries/preferences' 14import {useSetSelectedFeed} from '#/state/shell/selected-feed' 15import {atoms as a, useTheme} from '#/alf' 16import {Button, ButtonIcon, ButtonText} from '#/components/Button' 17import {InlineLinkText} from '#/components/Link' 18import {Loader} from '#/components/Loader' 19import * as Toast from '#/components/Toast' 20import {Text} from '#/components/Typography' 21 22export function FeedShutdownMsg({feedUri}: {feedUri: string}) { 23 const t = useTheme() 24 const {_} = useLingui() 25 const setSelectedFeed = useSetSelectedFeed() 26 const {data: preferences} = usePreferencesQuery() 27 const {mutateAsync: removeFeed, isPending: isRemovePending} = 28 useRemoveFeedMutation() 29 const {mutateAsync: replaceFeedWithDiscover, isPending: isReplacePending} = 30 useReplaceForYouWithDiscoverFeedMutation() 31 32 const feedConfig = preferences?.savedFeeds?.find( 33 f => f.value === feedUri && f.pinned, 34 ) 35 const discoverFeedConfig = preferences?.savedFeeds?.find( 36 f => f.value === PROD_DEFAULT_FEED('whats-hot'), 37 ) 38 const hasFeedPinned = Boolean(feedConfig) 39 const hasDiscoverPinned = Boolean(discoverFeedConfig?.pinned) 40 41 const onRemoveFeed = useCallback(async () => { 42 try { 43 if (feedConfig) { 44 await removeFeed(feedConfig) 45 Toast.show(_(msg`Removed from your feeds`)) 46 } 47 if (hasDiscoverPinned) { 48 setSelectedFeed(`feedgen|${PROD_DEFAULT_FEED('whats-hot')}`) 49 } 50 } catch (err: any) { 51 Toast.show( 52 _( 53 msg`There was an issue updating your feeds, please check your internet connection and try again.`, 54 ), 55 { 56 type: 'warning', 57 }, 58 ) 59 logger.error('Failed to update feeds', {message: err}) 60 } 61 }, [removeFeed, feedConfig, _, hasDiscoverPinned, setSelectedFeed]) 62 63 const onReplaceFeed = useCallback(async () => { 64 try { 65 await replaceFeedWithDiscover({ 66 forYouFeedConfig: feedConfig, 67 discoverFeedConfig, 68 }) 69 setSelectedFeed(`feedgen|${PROD_DEFAULT_FEED('whats-hot')}`) 70 Toast.show(_(msg`The feed has been replaced with Discover.`)) 71 } catch (err: any) { 72 Toast.show( 73 _( 74 msg`There was an issue updating your feeds, please check your internet connection and try again.`, 75 ), 76 { 77 type: 'warning', 78 }, 79 ) 80 logger.error('Failed to update feeds', {message: err}) 81 } 82 }, [ 83 replaceFeedWithDiscover, 84 discoverFeedConfig, 85 feedConfig, 86 setSelectedFeed, 87 _, 88 ]) 89 90 const isProcessing = isReplacePending || isRemovePending 91 return ( 92 <View 93 style={[ 94 a.py_3xl, 95 a.px_2xl, 96 a.gap_xl, 97 t.atoms.border_contrast_low, 98 a.border_t, 99 ]}> 100 <Text style={[a.text_5xl, a.font_semi_bold, t.atoms.text, a.text_center]}> 101 :( 102 </Text> 103 <Text style={[a.text_md, a.leading_snug, t.atoms.text, a.text_center]}> 104 <Trans> 105 This feed is no longer online. We are showing{' '} 106 <InlineLinkText 107 label={_(msg`The Discover feed`)} 108 to="/profile/bsky.app/feed/whats-hot" 109 style={[a.text_md]}> 110 Discover 111 </InlineLinkText>{' '} 112 instead. 113 </Trans> 114 </Text> 115 {hasFeedPinned ? ( 116 <View style={[a.flex_row, a.justify_center, a.gap_sm]}> 117 <Button 118 variant="outline" 119 color="primary" 120 size="small" 121 label={_(msg`Remove feed`)} 122 disabled={isProcessing} 123 onPress={onRemoveFeed}> 124 <ButtonText> 125 <Trans>Remove feed</Trans> 126 </ButtonText> 127 {isRemovePending && <ButtonIcon icon={Loader} />} 128 </Button> 129 {!hasDiscoverPinned && ( 130 <Button 131 variant="solid" 132 color="primary" 133 size="small" 134 label={_(msg`Replace with Discover`)} 135 disabled={isProcessing} 136 onPress={onReplaceFeed}> 137 <ButtonText> 138 <Trans>Replace with Discover</Trans> 139 </ButtonText> 140 {isReplacePending && <ButtonIcon icon={Loader} />} 141 </Button> 142 )} 143 </View> 144 ) : undefined} 145 </View> 146 ) 147}