deer social fork for personal usage. but you might see a use idk. github mirror
4
fork

Configure Feed

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

forgot to remove this part of the notifications

ayla 7fffec8f 2c6e11cf

+1 -64
+1 -64
src/screens/Settings/NotificationSettings/index.tsx
··· 1 - import {useEffect} from 'react' 2 - import {Linking, View} from 'react-native' 3 - import * as Notification from 'expo-notifications' 1 + import {View} from 'react-native' 4 2 import {type AppBskyNotificationDefs} from '@atproto/api' 5 3 import {msg, Trans} from '@lingui/macro' 6 4 import {useLingui} from '@lingui/react' 7 - import {useQuery, useQueryClient} from '@tanstack/react-query' 8 5 9 - import {useAppState} from '#/lib/hooks/useAppState' 10 6 import { 11 7 type AllNavigatorParams, 12 8 type NativeStackScreenProps, 13 9 } from '#/lib/routes/types' 14 - import {isAndroid, isIOS, isWeb} from '#/platform/detection' 15 10 import {useNotificationSettingsQuery} from '#/state/queries/notifications/settings' 16 11 import {atoms as a} from '#/alf' 17 12 import {Admonition} from '#/components/Admonition' 18 13 import {At_Stroke2_Corner2_Rounded as AtIcon} from '#/components/icons/At' 19 14 import {BellRinging_Stroke2_Corner0_Rounded as BellRingingIcon} from '#/components/icons/BellRinging' 20 15 import {Bubble_Stroke2_Corner2_Rounded as BubbleIcon} from '#/components/icons/Bubble' 21 - import {Haptic_Stroke2_Corner2_Rounded as HapticIcon} from '#/components/icons/Haptic' 22 16 import { 23 17 Heart2_Stroke2_Corner0_Rounded as HeartIcon, 24 18 LikeRepost_Stroke2_Corner2_Rounded as LikeRepostIcon, ··· 34 28 import * as SettingsList from '../components/SettingsList' 35 29 import {ItemTextWithSubtitle} from './components/ItemTextWithSubtitle' 36 30 37 - const RQKEY = ['notification-permissions'] 38 - 39 31 type Props = NativeStackScreenProps<AllNavigatorParams, 'NotificationSettings'> 40 32 export function NotificationSettingsScreen({}: Props) { 41 33 const {_} = useLingui() 42 - const queryClient = useQueryClient() 43 34 const {data: settings, isError} = useNotificationSettingsQuery() 44 35 45 - const {data: permissions, refetch} = useQuery({ 46 - queryKey: RQKEY, 47 - queryFn: async () => { 48 - if (isWeb) return null 49 - return await Notification.getPermissionsAsync() 50 - }, 51 - }) 52 - 53 - const appState = useAppState() 54 - useEffect(() => { 55 - if (appState === 'active') { 56 - refetch() 57 - } 58 - }, [appState, refetch]) 59 - 60 - const onRequestPermissions = async () => { 61 - if (isWeb) return 62 - if (permissions?.canAskAgain) { 63 - const response = await Notification.requestPermissionsAsync() 64 - queryClient.setQueryData(RQKEY, response) 65 - } else { 66 - if (isAndroid) { 67 - try { 68 - await Linking.sendIntent( 69 - 'android.settings.APP_NOTIFICATION_SETTINGS', 70 - [ 71 - { 72 - key: 'android.provider.extra.APP_PACKAGE', 73 - value: 'xyz.blueskyweb.app', 74 - }, 75 - ], 76 - ) 77 - } catch { 78 - Linking.openSettings() 79 - } 80 - } else if (isIOS) { 81 - Linking.openSettings() 82 - } 83 - } 84 - } 85 - 86 36 return ( 87 37 <Layout.Screen> 88 38 <Layout.Header.Outer> ··· 96 46 </Layout.Header.Outer> 97 47 <Layout.Content> 98 48 <SettingsList.Container> 99 - {permissions && !permissions.granted && ( 100 - <> 101 - <SettingsList.PressableItem 102 - label={_(msg`Enable push notifications`)} 103 - onPress={onRequestPermissions}> 104 - <SettingsList.ItemIcon icon={HapticIcon} /> 105 - <SettingsList.ItemText> 106 - <Trans>Enable push notifications</Trans> 107 - </SettingsList.ItemText> 108 - </SettingsList.PressableItem> 109 - <SettingsList.Divider /> 110 - </> 111 - )} 112 49 {isError && ( 113 50 <View style={[a.px_lg, a.pb_md]}> 114 51 <Admonition type="error">