import React from 'react' import {View} from 'react-native' import {AppBskyGraphDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQueryClient} from '@tanstack/react-query' import {useGoBack} from '#/lib/hooks/useGoBack' import {sanitizeHandle} from '#/lib/strings/handles' import {logger} from '#/logger' import {RQKEY_ROOT as listQueryRoot} from '#/state/queries/list' import {useListBlockMutation, useListMuteMutation} from '#/state/queries/list' import { type UsePreferencesQueryResponse, useRemoveFeedMutation, } from '#/state/queries/preferences' import {useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {CenteredView} from '#/view/com/util/Views' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash' import {Loader} from '#/components/Loader' import {useHider} from '#/components/moderation/Hider' import {Text} from '#/components/Typography' export function ListHiddenScreen({ list, preferences, }: { list: AppBskyGraphDefs.ListView preferences: UsePreferencesQueryResponse }) { const {_} = useLingui() const t = useTheme() const {currentAccount} = useSession() const {gtMobile} = useBreakpoints() const isOwner = currentAccount?.did === list.creator.did const goBack = useGoBack() const queryClient = useQueryClient() const isModList = list.purpose === AppBskyGraphDefs.MODLIST const [isProcessing, setIsProcessing] = React.useState(false) const listBlockMutation = useListBlockMutation() const listMuteMutation = useListMuteMutation() const {mutateAsync: removeSavedFeed} = useRemoveFeedMutation() const {setIsContentVisible} = useHider() const savedFeedConfig = preferences.savedFeeds.find(f => f.value === list.uri) const onUnsubscribe = async () => { setIsProcessing(true) if (list.viewer?.muted) { try { await listMuteMutation.mutateAsync({uri: list.uri, mute: false}) } catch (e) { setIsProcessing(false) logger.error('Failed to unmute list', {message: e}) Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) return } } if (list.viewer?.blocked) { try { await listBlockMutation.mutateAsync({uri: list.uri, block: false}) } catch (e) { setIsProcessing(false) logger.error('Failed to unblock list', {message: e}) Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) return } } queryClient.invalidateQueries({ queryKey: [listQueryRoot], }) Toast.show(_(msg`Unsubscribed from list`)) setIsProcessing(false) } const onRemoveList = async () => { if (!savedFeedConfig) return try { await removeSavedFeed(savedFeedConfig) Toast.show(_(msg`Removed from saved feeds`)) } catch (e) { logger.error('Failed to remove list from saved feeds', {message: e}) Toast.show( _( msg`There was an issue. Please check your internet connection and try again.`, ), ) } finally { setIsProcessing(false) } } return ( {list.creator.viewer?.blocking || list.creator.viewer?.blockedBy ? ( Creator has been blocked ) : ( List has been hidden )} {list.creator.viewer?.blocking || list.creator.viewer?.blockedBy ? ( Either the creator of this list has blocked you or you have blocked the creator. ) : isOwner ? ( This list – created by you – contains possible violations of Bluesky's community guidelines in its name or description. ) : ( This list – created by{' '} {sanitizeHandle(list.creator.handle, '@')} {' '} – contains possible violations of Bluesky's community guidelines in its name or description. )} {savedFeedConfig ? ( ) : null} {isOwner ? ( ) : list.viewer?.muted || list.viewer?.blocked ? ( ) : null} ) }