import React from 'react' import {StyleSheet, View} from 'react-native' import {useFocusEffect} from '@react-navigation/native' import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types' import {useNavigation} from '@react-navigation/native' import {observer} from 'mobx-react-lite' import {withAuthRequired} from 'view/com/auth/withAuthRequired' import {ViewHeader} from 'view/com/util/ViewHeader' import {CenteredView} from 'view/com/util/Views' import {ListItems} from 'view/com/lists/ListItems' import {EmptyState} from 'view/com/util/EmptyState' import {Button} from 'view/com/util/forms/Button' import * as Toast from 'view/com/util/Toast' import {ListModel} from 'state/models/content/list' import {useStores} from 'state/index' import {usePalette} from 'lib/hooks/usePalette' import {useSetTitle} from 'lib/hooks/useSetTitle' import {NavigationProp} from 'lib/routes/types' import {isDesktopWeb} from 'platform/detection' type Props = NativeStackScreenProps export const ProfileListScreen = withAuthRequired( observer(({route}: Props) => { const store = useStores() const navigation = useNavigation() const pal = usePalette('default') const {name, rkey} = route.params const list: ListModel = React.useMemo(() => { const model = new ListModel( store, `at://${name}/app.bsky.graph.list/${rkey}`, ) return model }, [store, name, rkey]) useSetTitle(list.list?.name) useFocusEffect( React.useCallback(() => { store.shell.setMinimalShellMode(false) list.loadMore(true) }, [store, list]), ) const onToggleSubscribed = React.useCallback(async () => { try { if (list.list?.viewer?.muted) { await list.unsubscribe() } else { await list.subscribe() } } catch (err) { Toast.show( 'There was an an issue updating your subscription, please check your internet connection and try again.', ) store.log.error('Failed up update subscription', {err}) } }, [store, list]) const onPressEditList = React.useCallback(() => { store.shell.openModal({ name: 'create-or-edit-mute-list', list, onSave() { list.refresh() }, }) }, [store, list]) const onPressDeleteList = React.useCallback(() => { store.shell.openModal({ name: 'confirm', title: 'Delete List', message: 'Are you sure?', async onPressConfirm() { await list.delete() if (navigation.canGoBack()) { navigation.goBack() } else { navigation.navigate('Home') } }, }) }, [store, list, navigation]) const renderEmptyState = React.useCallback(() => { return }, []) const renderHeaderBtns = React.useCallback(() => { return ( {list?.isOwner && (