···
import {useState} from 'react'
import {View} from 'react-native'
3
+
import {isDid} from '@atproto/api'
import {type ProfileViewBasic} from '@atproto/api/dist/client/types/app/bsky/actor/defs'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {type NativeStackScreenProps} from '@react-navigation/native-stack'
9
+
import {APPVIEW_DID_PROXY} from '#/lib/constants'
import {usePalette} from '#/lib/hooks/usePalette'
import {type CommonNavigatorParams} from '#/lib/routes/types'
import {type Gate} from '#/lib/statsig/gates'
···
useConstellationInstance,
useSetConstellationInstance,
} from '#/state/preferences/constellation-instance'
25
+
import {useCustomAppViewDid} from '#/state/preferences/custom-appview-did'
useDeerVerificationEnabled,
useDeerVerificationTrusted,
···
} from '#/state/preferences/show-link-in-handle.tsx'
import {useProfilesQuery} from '#/state/queries/profile'
113
+
import {findService, useDidDocument} from '#/state/queries/resolve-identity'
114
+
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
import * as SettingsList from '#/screens/Settings/components/SettingsList'
import {atoms as a, useBreakpoints} from '#/alf'
import {Admonition} from '#/components/Admonition'
···
import * as Layout from '#/components/Layout'
import {Text} from '#/components/Typography'
import {SearchProfileCard} from '../Search/components/SearchProfileCard'
type Props = NativeStackScreenProps<CommonNavigatorParams>
function ConstellationInstanceDialog({
···
208
+
function CustomAppViewDidDialog({
211
+
control: Dialog.DialogControlProps
213
+
const pal = usePalette('default')
214
+
const {_} = useLingui()
216
+
const [did, setDid] = useState('')
217
+
const [, setCustomAppViewDid] = useCustomAppViewDid()
219
+
const doc = useDidDocument({did})
220
+
const bskyAppViewService =
221
+
doc.data && findService(doc.data, '#bsky_appview', 'BskyAppView')
223
+
const submit = () => {
224
+
if (did.length === 0) {
225
+
setCustomAppViewDid(undefined)
229
+
if (!bskyAppViewService?.serviceEndpoint) return
230
+
setCustomAppViewDid(did)
237
+
nativeOptions={{preventExpansion: true}}
238
+
onClose={() => setDid('')}>
240
+
<Dialog.ScrollableInner label={_(msg`Custom AppView Proxy DID`)}>
241
+
<View style={[a.gap_sm, a.pb_lg]}>
242
+
<Text style={[a.text_2xl, a.font_bold]}>
243
+
<Trans>Custom AppView Proxy DID</Trans>
247
+
<View style={a.gap_lg}>
249
+
label="Text input field"
251
+
style={[styles.textInput, pal.border, pal.text]}
252
+
onChangeText={value => {
256
+
APPVIEW_DID_PROXY?.substring(0, APPVIEW_DID_PROXY.indexOf('#')) ||
257
+
`did:web:api.bsky.app`
259
+
placeholderTextColor={pal.colors.textLight}
260
+
onSubmitEditing={submit}
261
+
accessibilityHint={_(
262
+
msg`Input the DID of the AppView to proxy requests through`,
265
+
!!did && !bskyAppViewService?.serviceEndpoint && !doc.isLoading
269
+
{did && !isDid(did) && (
271
+
<ErrorMessage message={_(msg`must enter a DID`)} />
275
+
{did && (did.includes('#') || did.includes('?')) && (
277
+
<ErrorMessage message={_(msg`don't include the service id`)} />
285
+
doc.error.message || _(msg`document resolution failure`)
292
+
!bskyAppViewService &&
293
+
(doc.data as {message?: string}).message && (
296
+
message={(doc.data as {message: string}).message}
301
+
{doc.data && !bskyAppViewService && (
304
+
message={_(msg`document doesn't contain #bsky_appview service`)}
309
+
{bskyAppViewService && (
310
+
<Text style={[a.text_sm, a.leading_snug]}>
311
+
{JSON.stringify(bskyAppViewService, null, 2)}
315
+
<View style={isWeb && [a.flex_row, a.justify_end]}>
317
+
label={_(msg`Save`)}
321
+
color={did.length > 0 ? 'primary' : 'secondary'}
323
+
did.length !== 0 && !bskyAppViewService?.serviceEndpoint
326
+
{did.length > 0 ? <Trans>Save</Trans> : <Trans>Reset</Trans>}
333
+
</Dialog.ScrollableInner>
function TrustedVerifiersDialog({
···
472
+
const [customAppViewDid] = useCustomAppViewDid()
473
+
const setCustomAppViewDidControl = Dialog.useDialogControl()
···
618
+
<SettingsList.Item>
619
+
<SettingsList.ItemIcon icon={StarIcon} />
620
+
<SettingsList.ItemText>
621
+
<Trans>{`Custom AppView DID`}</Trans>
622
+
</SettingsList.ItemText>
623
+
<SettingsList.BadgeButton
624
+
label={customAppViewDid ? _(msg`Set`) : _(msg`Change`)}
625
+
onPress={() => setCustomAppViewDidControl.open()}
627
+
</SettingsList.Item>
628
+
<SettingsList.Item>
629
+
<Admonition type="info" style={[a.flex_1]}>
631
+
Restart app after changing your AppView.
632
+
{customAppViewDid && _(` Currently ${customAppViewDid}`)}
635
+
</SettingsList.Item>
<SettingsList.Group contentContainerStyle={[a.gap_sm]}>
<SettingsList.ItemIcon icon={PaintRollerIcon} />
···
</SettingsList.Container>
<ConstellationInstanceDialog control={setConstellationInstanceControl} />
959
+
<CustomAppViewDidDialog control={setCustomAppViewDidControl} />
<TrustedVerifiersDialog control={setTrustedVerifiersDialogControl} />