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

Configure Feed

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

at readme-update 109 lines 3.4 kB view raw
1import {View} from 'react-native' 2import {msg, Trans} from '@lingui/macro' 3import {useLingui} from '@lingui/react' 4 5import {useTrendingSettings} from '#/state/preferences/trending' 6import {atoms as a, useLayoutBreakpoints} from '#/alf' 7import {Button} from '#/components/Button' 8import {TimesLarge_Stroke2_Corner0_Rounded as CloseIcon} from '#/components/icons/Times' 9import {TrendingInterstitial} from '#/components/interstitials/Trending' 10import * as Toast from '#/components/Toast' 11import {LiveEventFeedCardWide} from '#/features/liveEvents/components/LiveEventFeedCardWide' 12import {useUserPreferencedLiveEvents} from '#/features/liveEvents/context' 13import {useUpdateLiveEventPreferences} from '#/features/liveEvents/preferences' 14import {type LiveEventFeed} from '#/features/liveEvents/types' 15 16export function DiscoverFeedLiveEventFeedsAndTrendingBanner() { 17 const events = useUserPreferencedLiveEvents() 18 const {rightNavVisible} = useLayoutBreakpoints() 19 const {trendingDisabled} = useTrendingSettings() 20 21 if (!events.feeds.length) { 22 if (!rightNavVisible && !trendingDisabled) { 23 // only show trending on mobile when live event banner is not shown 24 return <TrendingInterstitial /> 25 } else { 26 // no feed, no trending 27 return null 28 } 29 } 30 31 // On desktop, we show in the sidebar 32 if (rightNavVisible) return null 33 34 return events.feeds.map(feed => <Inner feed={feed} key={feed.id} />) 35} 36 37function Inner({feed}: {feed: LiveEventFeed}) { 38 const {_} = useLingui() 39 const layout = feed.layouts.wide 40 41 const {mutate: update, variables} = useUpdateLiveEventPreferences({ 42 feed, 43 metricContext: 'discover', 44 onUpdateSuccess({undoAction}) { 45 Toast.show( 46 <Toast.Outer> 47 <Toast.Icon /> 48 <Toast.Text> 49 {undoAction ? ( 50 <Trans>Live event hidden</Trans> 51 ) : ( 52 <Trans>Live event unhidden</Trans> 53 )} 54 </Toast.Text> 55 {undoAction && ( 56 <Toast.Action 57 label={_(msg`Undo`)} 58 onPress={() => { 59 if (undoAction) { 60 update(undoAction) 61 } 62 }}> 63 <Trans>Undo</Trans> 64 </Toast.Action> 65 )} 66 </Toast.Outer>, 67 {type: 'success'}, 68 ) 69 }, 70 }) 71 72 if (variables) return null 73 74 return ( 75 <> 76 <View style={[a.px_lg, a.pt_md, a.pb_xs]}> 77 <View> 78 <LiveEventFeedCardWide feed={feed} metricContext="discover" /> 79 80 <Button 81 label={_(msg`Dismiss live event banner`)} 82 size="tiny" 83 shape="round" 84 style={[a.absolute, a.z_10, {top: 6, right: 6}]} 85 onPress={() => { 86 update({type: 'hideFeed', id: feed.id}) 87 }}> 88 {({hovered, pressed}) => ( 89 <> 90 <View 91 style={[ 92 a.absolute, 93 a.inset_0, 94 a.rounded_full, 95 { 96 backgroundColor: layout.overlayColor, 97 opacity: hovered || pressed ? 0.8 : 0.6, 98 }, 99 ]} 100 /> 101 <CloseIcon size="xs" fill={layout.textColor} style={[a.z_20]} /> 102 </> 103 )} 104 </Button> 105 </View> 106 </View> 107 </> 108 ) 109}