Bluesky app fork with some witchin' additions 💫

make service url gate friendlier (#3841)

authored by samuel.fm and committed by

GitHub aeed4786 67b0cdf6

+32 -24
+32
src/screens/Messages/List/index.tsx
··· 6 6 import {msg, Trans} from '@lingui/macro' 7 7 import {useLingui} from '@lingui/react' 8 8 import {NativeStackScreenProps} from '@react-navigation/native-stack' 9 + import {sha256} from 'js-sha256' 9 10 10 11 import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' 11 12 import {MessagesTabNavigatorParams} from '#/lib/routes/types' ··· 25 26 import {DialogControlProps, useDialogControl} from '#/components/Dialog' 26 27 import {ConvoMenu} from '#/components/dms/ConvoMenu' 27 28 import {NewChat} from '#/components/dms/NewChat' 29 + import * as TextField from '#/components/forms/TextField' 28 30 import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' 29 31 import {SettingsSliderVertical_Stroke2_Corner0_Rounded as SettingsSlider} from '#/components/icons/SettingsSlider' 30 32 import {Link} from '#/components/Link' ··· 32 34 import {useMenuControl} from '#/components/Menu' 33 35 import {Text} from '#/components/Typography' 34 36 import {ClipClopGate} from '../gate' 37 + import {useDmServiceUrlStorage} from '../Temp/useDmServiceUrlStorage' 35 38 36 39 type Props = NativeStackScreenProps<MessagesTabNavigatorParams, 'Messages'> 37 40 export function MessagesScreen({navigation}: Props) { ··· 39 42 const t = useTheme() 40 43 const newChatControl = useDialogControl() 41 44 const {gtMobile} = useBreakpoints() 45 + 46 + // TEMP 47 + const {serviceUrl, setServiceUrl} = useDmServiceUrlStorage() 48 + const hasValidServiceUrl = useMemo(() => { 49 + const hash = sha256(serviceUrl) 50 + return ( 51 + hash === 52 + 'a32318b49dd3fe6aa6a35c66c13fcc4c1cb6202b24f5a852d9a2279acee4169f' 53 + ) 54 + }, [serviceUrl]) 42 55 43 56 const renderButton = useCallback(() => { 44 57 return ( ··· 111 124 112 125 const gate = useGate() 113 126 if (!gate('dms')) return <ClipClopGate /> 127 + 128 + if (!hasValidServiceUrl) { 129 + return ( 130 + <CenteredView sideBorders style={[a.flex_1, a.p_md]}> 131 + <View> 132 + <TextField.LabelText>Service URL</TextField.LabelText> 133 + <TextField.Root> 134 + <TextField.Input 135 + value={serviceUrl} 136 + onChangeText={text => setServiceUrl(text)} 137 + autoCapitalize="none" 138 + keyboardType="url" 139 + label="https://" 140 + /> 141 + </TextField.Root> 142 + </View> 143 + </CenteredView> 144 + ) 145 + } 114 146 115 147 if (conversations.length < 1) { 116 148 return (
-24
src/view/screens/Settings/index.tsx
··· 50 50 import {makeProfileLink} from 'lib/routes/links' 51 51 import {CommonNavigatorParams, NativeStackScreenProps} from 'lib/routes/types' 52 52 import {NavigationProp} from 'lib/routes/types' 53 - import {useGate} from 'lib/statsig/statsig' 54 53 import {colors, s} from 'lib/styles' 55 54 import {AccountDropdownBtn} from 'view/com/util/AccountDropdownBtn' 56 55 import {SelectableBtn} from 'view/com/util/forms/SelectableBtn' ··· 61 60 import * as Toast from 'view/com/util/Toast' 62 61 import {UserAvatar} from 'view/com/util/UserAvatar' 63 62 import {ScrollView} from 'view/com/util/Views' 64 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 65 63 import {useTheme} from '#/alf' 66 64 import {useDialogControl} from '#/components/Dialog' 67 65 import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings' 68 - import * as TextField from '#/components/forms/TextField' 69 66 import {navigate, resetToTab} from '#/Navigation' 70 67 import {Email2FAToggle} from './Email2FAToggle' 71 68 import {ExportCarDialog} from './ExportCarDialog' ··· 189 186 const birthdayControl = useDialogControl() 190 187 const {pendingDid, onPressSwitchAccount} = useAccountSwitcher() 191 188 const isSwitchingAccounts = !!pendingDid 192 - 193 - // TODO: TEMP REMOVE WHEN CLOPS ARE RELEASED 194 - const gate = useGate() 195 - const {serviceUrl: dmServiceUrl, setServiceUrl: setDmServiceUrl} = 196 - useDmServiceUrlStorage() 197 189 198 190 // const primaryBg = useCustomPalette<ViewStyle>({ 199 191 // light: {backgroundColor: colors.blue0}, ··· 807 799 <Trans>System log</Trans> 808 800 </Text> 809 801 </TouchableOpacity> 810 - {gate('dms') && ( 811 - <TextField.Root> 812 - <TextField.Input 813 - value={dmServiceUrl} 814 - onChangeText={(text: string) => { 815 - if (text.length > 9 && text.endsWith('/')) { 816 - text = text.slice(0, -1) 817 - } 818 - setDmServiceUrl(text) 819 - }} 820 - autoCapitalize="none" 821 - keyboardType="url" 822 - label="🐴" 823 - /> 824 - </TextField.Root> 825 - )} 826 802 {__DEV__ ? ( 827 803 <> 828 804 <TouchableOpacity