Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
119
fork

Configure Feed

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

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