Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32177710
D8806.1765069889.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D8806.1765069889.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 1:11 AM (20 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5841882
Default Alt Text
D8806.1765069889.diff (2 KB)
Attached To
Mode
D8806: [native] Prevent simulators from attempting to open the barcode scanner
Attached
Detach File
Event Timeline
Log In to Comment