about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2024-05-14 21:19:22 +0100
committerGitHub <noreply@github.com>2024-05-14 21:19:22 +0100
commit0e04b19627f163e36089caca78614bfa4c45403e (patch)
treef315ef7ee94730cc61108836be5454326ad96011 /src
parentebc75713681fc431cd2d33aeb1ca80758a5ffda6 (diff)
downloadvoidsky-0e04b19627f163e36089caca78614bfa4c45403e.tar.zst
remove serviceurl gate (#4019)
Diffstat (limited to 'src')
-rw-r--r--src/screens/Messages/List/index.tsx42
-rw-r--r--src/screens/Messages/Temp/useDmServiceUrlStorage.tsx70
-rw-r--r--src/state/preferences/index.tsx5
3 files changed, 1 insertions, 116 deletions
diff --git a/src/screens/Messages/List/index.tsx b/src/screens/Messages/List/index.tsx
index 5c9b93fcd..6300a976b 100644
--- a/src/screens/Messages/List/index.tsx
+++ b/src/screens/Messages/List/index.tsx
@@ -4,7 +4,6 @@ import {ChatBskyConvoDefs} from '@atproto/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'
@@ -15,12 +14,10 @@ import {useListConvos} from '#/state/queries/messages/list-converations'
 import {List} from '#/view/com/util/List'
 import {ViewHeader} from '#/view/com/util/ViewHeader'
 import {CenteredView} from '#/view/com/util/Views'
-import {ScrollView} from '#/view/com/util/Views'
 import {atoms as a, useBreakpoints, useTheme} from '#/alf'
 import {Button, ButtonIcon, ButtonText} from '#/components/Button'
 import {DialogControlProps, useDialogControl} from '#/components/Dialog'
 import {NewChat} from '#/components/dms/NewChat'
-import * as TextField from '#/components/forms/TextField'
 import {useRefreshOnFocus} from '#/components/hooks/useRefreshOnFocus'
 import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
 import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
@@ -28,7 +25,6 @@ import {Link} from '#/components/Link'
 import {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
 import {Text} from '#/components/Typography'
 import {ClipClopGate} from '../gate'
-import {useDmServiceUrlStorage} from '../Temp/useDmServiceUrlStorage'
 import {ChatListItem} from './ChatListItem'
 
 type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'>
@@ -54,17 +50,6 @@ export function MessagesScreen({navigation, route}: Props) {
   const {gtMobile} = useBreakpoints()
   const pushToConversation = route.params?.pushToConversation
 
-  // TEMP
-  const {serviceUrl, setServiceUrl} = useDmServiceUrlStorage()
-  const [serviceUrlValue, setServiceUrlValue] = useState(serviceUrl)
-  const hasValidServiceUrl = useMemo(() => {
-    const hash = sha256(serviceUrl)
-    return (
-      hash ===
-      'a32318b49dd3fe6aa6a35c66c13fcc4c1cb6202b24f5a852d9a2279acee4169f'
-    )
-  }, [serviceUrl])
-
   // Whenever we have `pushToConversation` set, it means we pressed a notification for a chat without being on
   // this tab. We should immediately push to the conversation after pressing the notification.
   // After we push, reset with `setParams` so that this effect will fire next time we press a notification, even if
@@ -145,33 +130,6 @@ export function MessagesScreen({navigation, route}: Props) {
   const gate = useGate()
   if (!gate('dms')) return <ClipClopGate />
 
-  if (!hasValidServiceUrl) {
-    return (
-      <ScrollView contentContainerStyle={a.p_lg}>
-        <View>
-          <TextField.LabelText>Service URL</TextField.LabelText>
-          <TextField.Root>
-            <TextField.Input
-              value={serviceUrlValue}
-              onChangeText={text => setServiceUrlValue(text)}
-              autoCapitalize="none"
-              keyboardType="url"
-              label="https://"
-            />
-          </TextField.Root>
-          <Button
-            label="Set Service URL"
-            size="small"
-            variant="solid"
-            color="primary"
-            onPress={() => setServiceUrl(serviceUrlValue)}>
-            <ButtonText>Set</ButtonText>
-          </Button>
-        </View>
-      </ScrollView>
-    )
-  }
-
   if (conversations.length < 1) {
     return (
       <View style={a.flex_1}>
diff --git a/src/screens/Messages/Temp/useDmServiceUrlStorage.tsx b/src/screens/Messages/Temp/useDmServiceUrlStorage.tsx
deleted file mode 100644
index 0e3f87603..000000000
--- a/src/screens/Messages/Temp/useDmServiceUrlStorage.tsx
+++ /dev/null
@@ -1,70 +0,0 @@
-import React from 'react'
-import {useAsyncStorage} from '@react-native-async-storage/async-storage'
-
-/**
- * TEMP: REMOVE BEFORE RELEASE
- *
- * Clip clop trivia:
- *
- * A little known fact about the term "clip clop" is that it may refer to a unit of time. It is unknown what the exact
- * length of a clip clop is, but it is generally agreed that it is approximately 9 minutes and 30 seconds, or 570
- * seconds.
- *
- * The term "clip clop" may also be used in other contexts, although it is unknown what all of these contexts may be.
- * Recently, the term has been used among many young adults to refer to a type of social media functionality, although
- * the exact nature of this functionality is also unknown. It is believed that the term may have originated from a
- * popular video game, but this has not been confirmed.
- *
- */
-
-const DmServiceUrlStorageContext = React.createContext<{
-  serviceUrl: string
-  setServiceUrl: (value: string) => void
-}>({
-  serviceUrl: '',
-  setServiceUrl: () => {},
-})
-
-export const useDmServiceUrlStorage = () =>
-  React.useContext(DmServiceUrlStorageContext)
-
-export function DmServiceUrlProvider({children}: {children: React.ReactNode}) {
-  const [serviceUrl, setServiceUrl] = React.useState<string>('')
-  const {getItem, setItem: setItemInner} = useAsyncStorage('dmServiceUrl')
-
-  React.useEffect(() => {
-    ;(async () => {
-      const v = await getItem()
-      try {
-        if (v) {
-          new URL(v)
-          setServiceUrl(v)
-        }
-      } catch (e) {
-        console.error('Invalid service URL stored in async storage:', v)
-      }
-    })()
-  }, [getItem])
-
-  const setItem = React.useCallback(
-    (v: string) => {
-      setItemInner(v)
-      setServiceUrl(v)
-    },
-    [setItemInner],
-  )
-
-  const value = React.useMemo(
-    () => ({
-      serviceUrl,
-      setServiceUrl: setItem,
-    }),
-    [serviceUrl, setItem],
-  )
-
-  return (
-    <DmServiceUrlStorageContext.Provider value={value}>
-      {children}
-    </DmServiceUrlStorageContext.Provider>
-  )
-}
diff --git a/src/state/preferences/index.tsx b/src/state/preferences/index.tsx
index 5bca35452..70c8efc80 100644
--- a/src/state/preferences/index.tsx
+++ b/src/state/preferences/index.tsx
@@ -1,6 +1,5 @@
 import React from 'react'
 
-import {DmServiceUrlProvider} from '#/screens/Messages/Temp/useDmServiceUrlStorage'
 import {Provider as AltTextRequiredProvider} from './alt-text-required'
 import {Provider as AutoplayProvider} from './autoplay'
 import {Provider as DisableHapticsProvider} from './disable-haptics'
@@ -33,9 +32,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
             <InAppBrowserProvider>
               <DisableHapticsProvider>
                 <AutoplayProvider>
-                  <DmServiceUrlProvider>
-                    <KawaiiProvider>{children}</KawaiiProvider>
-                  </DmServiceUrlProvider>
+                  <KawaiiProvider>{children}</KawaiiProvider>
                 </AutoplayProvider>
               </DisableHapticsProvider>
             </InAppBrowserProvider>