forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {type AppBskyNotificationDeclaration} from '@atproto/api'
2import {msg, Trans} from '@lingui/macro'
3import {useLingui} from '@lingui/react'
4import {type NativeStackScreenProps} from '@react-navigation/native-stack'
5
6import {type CommonNavigatorParams} from '#/lib/routes/types'
7import {useNotificationDeclarationQuery} from '#/state/queries/activity-subscriptions'
8import {useAppPasswordsQuery} from '#/state/queries/app-passwords'
9import {useSession} from '#/state/session'
10import * as SettingsList from '#/screens/Settings/components/SettingsList'
11import {atoms as a, useTheme} from '#/alf'
12import * as Admonition from '#/components/Admonition'
13import {BellRinging_Stroke2_Corner0_Rounded as BellRingingIcon} from '#/components/icons/BellRinging'
14import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlashIcon} from '#/components/icons/EyeSlash'
15import {Key_Stroke2_Corner2_Rounded as KeyIcon} from '#/components/icons/Key'
16import {ShieldCheck_Stroke2_Corner0_Rounded as ShieldIcon} from '#/components/icons/Shield'
17import * as Layout from '#/components/Layout'
18import {InlineLinkText} from '#/components/Link'
19import {Email2FAToggle} from './components/Email2FAToggle'
20import {PwiOptOut} from './components/PwiOptOut'
21import {ItemTextWithSubtitle} from './NotificationSettings/components/ItemTextWithSubtitle'
22
23type Props = NativeStackScreenProps<
24 CommonNavigatorParams,
25 'PrivacyAndSecuritySettings'
26>
27export function PrivacyAndSecuritySettingsScreen({}: Props) {
28 const {_} = useLingui()
29 const t = useTheme()
30 const {data: appPasswords} = useAppPasswordsQuery()
31 const {currentAccount} = useSession()
32 const {
33 data: notificationDeclaration,
34 isPending,
35 isError,
36 } = useNotificationDeclarationQuery()
37
38 return (
39 <Layout.Screen>
40 <Layout.Header.Outer>
41 <Layout.Header.BackButton />
42 <Layout.Header.Content>
43 <Layout.Header.TitleText>
44 <Trans>Privacy and Security</Trans>
45 </Layout.Header.TitleText>
46 </Layout.Header.Content>
47 <Layout.Header.Slot />
48 </Layout.Header.Outer>
49 <Layout.Content>
50 <SettingsList.Container>
51 <SettingsList.Item>
52 <SettingsList.ItemIcon
53 icon={ShieldIcon}
54 color={
55 currentAccount?.emailAuthFactor
56 ? t.palette.primary_500
57 : undefined
58 }
59 />
60 <SettingsList.ItemText>
61 {currentAccount?.emailAuthFactor ? (
62 <Trans>Email 2FA enabled</Trans>
63 ) : (
64 <Trans>Two-factor authentication (2FA)</Trans>
65 )}
66 </SettingsList.ItemText>
67 <Email2FAToggle />
68 </SettingsList.Item>
69 <SettingsList.LinkItem
70 to="/settings/app-passwords"
71 label={_(msg`App passwords`)}>
72 <SettingsList.ItemIcon icon={KeyIcon} />
73 <SettingsList.ItemText>
74 <Trans>App passwords</Trans>
75 </SettingsList.ItemText>
76 {appPasswords && appPasswords.length > 0 && (
77 <SettingsList.BadgeText>
78 {appPasswords.length}
79 </SettingsList.BadgeText>
80 )}
81 </SettingsList.LinkItem>
82 <SettingsList.LinkItem
83 label={_(
84 msg`Settings for allowing others to be notified of your skeets`,
85 )}
86 to={{screen: 'ActivityPrivacySettings'}}
87 contentContainerStyle={[a.align_start]}>
88 <SettingsList.ItemIcon icon={BellRingingIcon} />
89 <ItemTextWithSubtitle
90 titleText={
91 <Trans>Allow others to be notified of your skeets</Trans>
92 }
93 subtitleText={
94 <NotificationDeclaration
95 data={notificationDeclaration}
96 isError={isError}
97 />
98 }
99 showSkeleton={isPending}
100 />
101 </SettingsList.LinkItem>
102 <SettingsList.Divider />
103 <SettingsList.Group>
104 <SettingsList.ItemIcon icon={EyeSlashIcon} />
105 <SettingsList.ItemText>
106 <Trans>Logged-out visibility</Trans>
107 </SettingsList.ItemText>
108 <PwiOptOut />
109 </SettingsList.Group>
110 <SettingsList.Item>
111 <Admonition.Outer type="tip" style={[a.flex_1]}>
112 <Admonition.Row>
113 <Admonition.Icon />
114 <Admonition.Content>
115 <Admonition.Text>
116 <Trans>
117 Note: Bluesky is an open and public network. This setting
118 only limits the visibility of your content on the Bluesky
119 app and website, and other apps may not respect this
120 setting. Your content may still be shown to logged-out
121 users by other apps and websites.
122 </Trans>
123 </Admonition.Text>
124 <Admonition.Text>
125 <InlineLinkText
126 label={_(
127 msg`Learn more about what is public on Bluesky.`,
128 )}
129 to="https://blueskyweb.zendesk.com/hc/en-us/articles/15835264007693-Data-Privacy">
130 <Trans>Learn more about what is public on Bluesky.</Trans>
131 </InlineLinkText>
132 </Admonition.Text>
133 </Admonition.Content>
134 </Admonition.Row>
135 </Admonition.Outer>
136 </SettingsList.Item>
137 </SettingsList.Container>
138 </Layout.Content>
139 </Layout.Screen>
140 )
141}
142
143function NotificationDeclaration({
144 data,
145 isError,
146}: {
147 data?: {
148 value: AppBskyNotificationDeclaration.Record
149 }
150 isError?: boolean
151}) {
152 if (isError) {
153 return <Trans>Error loading preference</Trans>
154 }
155 switch (data?.value?.allowSubscriptions) {
156 case 'mutuals':
157 return <Trans>Only followers who I follow</Trans>
158 case 'none':
159 return <Trans>No one</Trans>
160 case 'followers':
161 default:
162 return <Trans>Anyone who follows me</Trans>
163 }
164}