import {View} from 'react-native' import {msg} from '@lingui/core/macro' import {useLingui} from '@lingui/react' import {Trans} from '@lingui/react/macro' import {useTrendingSettings} from '#/state/preferences/trending' import {atoms as a, useLayoutBreakpoints} from '#/alf' import {Button} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as CloseIcon} from '#/components/icons/Times' import {TrendingInterstitial} from '#/components/interstitials/Trending' import * as Toast from '#/components/Toast' import {LiveEventFeedCardWide} from '#/features/liveEvents/components/LiveEventFeedCardWide' import {useUserPreferencedLiveEvents} from '#/features/liveEvents/context' import {useUpdateLiveEventPreferences} from '#/features/liveEvents/preferences' import {type LiveEventFeed} from '#/features/liveEvents/types' export function DiscoverFeedLiveEventFeedsAndTrendingBanner() { const events = useUserPreferencedLiveEvents() const {rightNavVisible} = useLayoutBreakpoints() const {trendingDisabled} = useTrendingSettings() if (!events.feeds.length) { if (!rightNavVisible && !trendingDisabled) { // only show trending on mobile when live event banner is not shown return } else { // no feed, no trending return null } } // On desktop, we show in the sidebar if (rightNavVisible) return null return events.feeds.map(feed => ) } function Inner({feed}: {feed: LiveEventFeed}) { const {_} = useLingui() const layout = feed.layouts.wide const {mutate: update, variables} = useUpdateLiveEventPreferences({ feed, metricContext: 'discover', onUpdateSuccess({undoAction}) { Toast.show( {undoAction ? ( Live event hidden ) : ( Live event unhidden )} {undoAction && ( { if (undoAction) { update(undoAction) } }}> Undo )} , {type: 'success'}, ) }, }) if (variables) return null return ( <> ) }