Bluesky app fork with some witchin' additions 💫

Handle invalid service URLs (#3908)

authored by

Eric Bailey and committed by
GitHub
31a8356a 165fdb70

+19 -3
+11 -2
src/screens/Messages/List/index.tsx
··· 47 47 48 48 // TEMP 49 49 const {serviceUrl, setServiceUrl} = useDmServiceUrlStorage() 50 + const [serviceUrlValue, setServiceUrlValue] = useState(serviceUrl) 50 51 const hasValidServiceUrl = useMemo(() => { 51 52 const hash = sha256(serviceUrl) 52 53 return ( ··· 136 137 <TextField.LabelText>Service URL</TextField.LabelText> 137 138 <TextField.Root> 138 139 <TextField.Input 139 - value={serviceUrl} 140 - onChangeText={text => setServiceUrl(text)} 140 + value={serviceUrlValue} 141 + onChangeText={text => setServiceUrlValue(text)} 141 142 autoCapitalize="none" 142 143 keyboardType="url" 143 144 label="https://" 144 145 /> 145 146 </TextField.Root> 147 + <Button 148 + label="Set Service URL" 149 + size="small" 150 + variant="solid" 151 + color="primary" 152 + onPress={() => setServiceUrl(serviceUrlValue)}> 153 + <ButtonText>Set</ButtonText> 154 + </Button> 146 155 </View> 147 156 </ScrollView> 148 157 )
+8 -1
src/screens/Messages/Temp/useDmServiceUrlStorage.tsx
··· 35 35 React.useEffect(() => { 36 36 ;(async () => { 37 37 const v = await getItem() 38 - setServiceUrl(v ?? '') 38 + try { 39 + if (v) { 40 + new URL(v) 41 + setServiceUrl(v) 42 + } 43 + } catch (e) { 44 + console.error('Invalid service URL stored in async storage:', v) 45 + } 39 46 })() 40 47 }, [getItem]) 41 48