about summary refs log tree commit diff
path: root/src/screens/Messages/List/index.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-05-03 16:32:20 +0100
committerGitHub <noreply@github.com>2024-05-03 16:32:20 +0100
commitaeed4786db28e9efcf41ed81ab06c108fa8e3fc0 (patch)
treee11611f5eb8fda4f5c117b2ed47de70429c3dab9 /src/screens/Messages/List/index.tsx
parent67b0cdf649c4735be0e1feb69a919e41e45f593a (diff)
downloadvoidsky-aeed4786db28e9efcf41ed81ab06c108fa8e3fc0.tar.zst
make service url gate friendlier (#3841)
Diffstat (limited to 'src/screens/Messages/List/index.tsx')
-rw-r--r--src/screens/Messages/List/index.tsx32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/screens/Messages/List/index.tsx b/src/screens/Messages/List/index.tsx
index df22ff2b4..d97ddc699 100644
--- a/src/screens/Messages/List/index.tsx
+++ b/src/screens/Messages/List/index.tsx
@@ -6,6 +6,7 @@ import {ChatBskyConvoDefs} from '@atproto-labs/api'
 import {msg, Trans} from '@lingui/macro'
 import {useLingui} from '@lingui/react'
 import {NativeStackScreenProps} from '@react-navigation/native-stack'
+import {sha256} from 'js-sha256'
 
 import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
 import {MessagesTabNavigatorParams} from '#/lib/routes/types'
@@ -25,6 +26,7 @@ import {Button, ButtonIcon, ButtonText} from '#/components/Button'
 import {DialogControlProps, useDialogControl} from '#/components/Dialog'
 import {ConvoMenu} from '#/components/dms/ConvoMenu'
 import {NewChat} from '#/components/dms/NewChat'
+import * as TextField from '#/components/forms/TextField'
 import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
 import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
 import {Link} from '#/components/Link'
@@ -32,6 +34,7 @@ import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
 import {useMenuControl} from '#/components/Menu'
 import {Text} from '#/components/Typography'
 import {ClipClopGate} from '../gate'
+import {useDmServiceUrlStorage} from '../Temp/useDmServiceUrlStorage'
 
 type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'>
 export function MessagesScreen({navigation}: Props) {
@@ -40,6 +43,16 @@ export function MessagesScreen({navigation}: Props) {
   const newChatControl = useDialogControl()
   const {gtMobile} = useBreakpoints()
 
+  // TEMP
+  const {serviceUrl, setServiceUrl} = useDmServiceUrlStorage()
+  const hasValidServiceUrl = useMemo(() => {
+    const hash = sha256(serviceUrl)
+    return (
+      hash ===
+      'a32318b49dd3fe6aa6a35c66c13fcc4c1cb6202b24f5a852d9a2279acee4169f'
+    )
+  }, [serviceUrl])
+
   const renderButton = useCallback(() => {
     return (
       <Link
@@ -112,6 +125,25 @@ export function MessagesScreen({navigation}: Props) {
   const gate = useGate()
   if (!gate('dms')) return <ClipClopGate />
 
+  if (!hasValidServiceUrl) {
+    return (
+      <CenteredView sideBorders style={[a.flex_1, a.p_md]}>
+        <View>
+          <TextField.LabelText>Service URL</TextField.LabelText>
+          <TextField.Root>
+            <TextField.Input
+              value={serviceUrl}
+              onChangeText={text => setServiceUrl(text)}
+              autoCapitalize="none"
+              keyboardType="url"
+              label="https://"
+            />
+          </TextField.Root>
+        </View>
+      </CenteredView>
+    )
+  }
+
   if (conversations.length < 1) {
     return (
       <View style={a.flex_1}>