import {useCallback} from 'react' import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type CommonNavigatorParams} from '#/lib/routes/types' import {isNative} from '#/platform/detection' import {useUpdateActorDeclaration} from '#/state/queries/messages/actor-declaration' import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {atoms as a} from '#/alf' import {Admonition} from '#/components/Admonition' import {Divider} from '#/components/Divider' import * as Toggle from '#/components/forms/Toggle' import * as Layout from '#/components/Layout' import {Text} from '#/components/Typography' import {useBackgroundNotificationPreferences} from '../../../modules/expo-background-notification-handler/src/BackgroundNotificationHandlerProvider' type AllowIncoming = 'all' | 'none' | 'following' type Props = NativeStackScreenProps export function MessagesSettingsScreen({}: Props) { const {_} = useLingui() const {currentAccount} = useSession() const {data: profile} = useProfileQuery({ did: currentAccount!.did, }) const {preferences, setPref} = useBackgroundNotificationPreferences() const {mutate: updateDeclaration} = useUpdateActorDeclaration({ onError: () => { Toast.show(_(msg`Failed to update settings`), 'xmark') }, }) const onSelectMessagesFrom = useCallback( (keys: string[]) => { const key = keys[0] if (!key) return updateDeclaration(key as AllowIncoming) }, [updateDeclaration], ) const onSelectSoundSetting = useCallback( (keys: string[]) => { const key = keys[0] if (!key) return setPref('playSoundChat', key === 'enabled') }, [setPref], ) return ( Chat Settings Allow new messages from Everyone Users I follow No one You can continue ongoing conversations regardless of which setting you choose. {isNative && ( <> Notification Sounds Enabled Disabled )} ) }