remove serviceurl gate (#4019)
parent
ebc7571368
commit
0e04b19627
|
@ -4,7 +4,6 @@ import {ChatBskyConvoDefs} from '@atproto/api'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
import {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||||
import {sha256} from 'js-sha256'
|
|
||||||
|
|
||||||
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
|
||||||
import {MessagesTabNavigatorParams} from '#/lib/routes/types'
|
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 {List} from '#/view/com/util/List'
|
||||||
import {ViewHeader} from '#/view/com/util/ViewHeader'
|
import {ViewHeader} from '#/view/com/util/ViewHeader'
|
||||||
import {CenteredView} from '#/view/com/util/Views'
|
import {CenteredView} from '#/view/com/util/Views'
|
||||||
import {ScrollView} from '#/view/com/util/Views'
|
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import {DialogControlProps, useDialogControl} from '#/components/Dialog'
|
import {DialogControlProps, useDialogControl} from '#/components/Dialog'
|
||||||
import {NewChat} from '#/components/dms/NewChat'
|
import {NewChat} from '#/components/dms/NewChat'
|
||||||
import * as TextField from '#/components/forms/TextField'
|
|
||||||
import {useRefreshOnFocus} from '#/components/hooks/useRefreshOnFocus'
|
import {useRefreshOnFocus} from '#/components/hooks/useRefreshOnFocus'
|
||||||
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus'
|
||||||
import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider'
|
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 {ListFooter, ListMaybePlaceholder} from '#/components/Lists'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {ClipClopGate} from '../gate'
|
import {ClipClopGate} from '../gate'
|
||||||
import {useDmServiceUrlStorage} from '../Temp/useDmServiceUrlStorage'
|
|
||||||
import {ChatListItem} from './ChatListItem'
|
import {ChatListItem} from './ChatListItem'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'>
|
type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'>
|
||||||
|
@ -54,17 +50,6 @@ export function MessagesScreen({navigation, route}: Props) {
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const pushToConversation = route.params?.pushToConversation
|
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
|
// 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.
|
// 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
|
// 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()
|
const gate = useGate()
|
||||||
if (!gate('dms')) return <ClipClopGate />
|
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) {
|
if (conversations.length < 1) {
|
||||||
return (
|
return (
|
||||||
<View style={a.flex_1}>
|
<View style={a.flex_1}>
|
||||||
|
|
|
@ -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>
|
|
||||||
)
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {DmServiceUrlProvider} from '#/screens/Messages/Temp/useDmServiceUrlStorage'
|
|
||||||
import {Provider as AltTextRequiredProvider} from './alt-text-required'
|
import {Provider as AltTextRequiredProvider} from './alt-text-required'
|
||||||
import {Provider as AutoplayProvider} from './autoplay'
|
import {Provider as AutoplayProvider} from './autoplay'
|
||||||
import {Provider as DisableHapticsProvider} from './disable-haptics'
|
import {Provider as DisableHapticsProvider} from './disable-haptics'
|
||||||
|
@ -33,9 +32,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
<InAppBrowserProvider>
|
<InAppBrowserProvider>
|
||||||
<DisableHapticsProvider>
|
<DisableHapticsProvider>
|
||||||
<AutoplayProvider>
|
<AutoplayProvider>
|
||||||
<DmServiceUrlProvider>
|
<KawaiiProvider>{children}</KawaiiProvider>
|
||||||
<KawaiiProvider>{children}</KawaiiProvider>
|
|
||||||
</DmServiceUrlProvider>
|
|
||||||
</AutoplayProvider>
|
</AutoplayProvider>
|
||||||
</DisableHapticsProvider>
|
</DisableHapticsProvider>
|
||||||
</InAppBrowserProvider>
|
</InAppBrowserProvider>
|
||||||
|
|
Loading…
Reference in New Issue