Page MenuHomePhabricator

D8806.id29923.diff
No OneTemporary

D8806.id29923.diff

diff --git a/native/profile/linked-devices-header-right-button.react.js b/native/profile/linked-devices-header-right-button.react.js
--- a/native/profile/linked-devices-header-right-button.react.js
+++ b/native/profile/linked-devices-header-right-button.react.js
@@ -6,15 +6,25 @@
import { SecondaryDeviceQRCodeScannerRouteName } from '../navigation/route-names.js';
import { useStyles } from '../themes/colors.js';
+import Alert from '../utils/alert.js';
+import { deviceIsEmulator } from '../utils/url-utils.js';
function LinkedDevicesHeaderRightButton(): React.Node {
const styles = useStyles(unboundStyles);
- const navigation = useNavigation();
+ const { navigate } = useNavigation();
- const navigateToQRCodeScanner = React.useCallback(
- () => navigation.navigate(SecondaryDeviceQRCodeScannerRouteName),
- [navigation],
- );
+ const navigateToQRCodeScanner = React.useCallback(() => {
+ if (deviceIsEmulator) {
+ Alert.alert(
+ 'Unsupported device',
+ "You can't access the QR code scanner on a simulator.",
+ [{ text: 'OK' }],
+ { cancelable: false },
+ );
+ return;
+ }
+ navigate(SecondaryDeviceQRCodeScannerRouteName);
+ }, [navigate]);
return (
<TouchableOpacity onPress={navigateToQRCodeScanner}>
diff --git a/native/utils/url-utils.js b/native/utils/url-utils.js
--- a/native/utils/url-utils.js
+++ b/native/utils/url-utils.js
@@ -15,12 +15,12 @@
const productionNodeServerURL = 'https://squadcal.org';
const productionLandingURL = 'https://comm.app';
-const devIsEmulator: boolean = __DEV__ && DeviceInfo.isEmulatorSync();
+const deviceIsEmulator: boolean = __DEV__ && DeviceInfo.isEmulatorSync();
// ESLint doesn't recognize that invariant always throws
// eslint-disable-next-line consistent-return
function getDevServerHostname(): string {
- if (!devIsEmulator) {
+ if (!deviceIsEmulator) {
checkForMissingNatDevHostname();
return natDevHostname;
} else if (Platform.OS === 'android') {
@@ -78,4 +78,5 @@
natNodeServer,
setCustomServer,
normalizeURL,
+ deviceIsEmulator,
};

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 7:34 AM (21 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2534262
Default Alt Text
D8806.id29923.diff (2 KB)

Event Timeline