Page MenuHomePhabricator

D14153.id46390.diff
No OneTemporary

D14153.id46390.diff

diff --git a/native/account/qr-auth/qr-auth-context-provider.js b/native/account/qr-auth/qr-auth-context-provider.js
--- a/native/account/qr-auth/qr-auth-context-provider.js
+++ b/native/account/qr-auth/qr-auth-context-provider.js
@@ -29,6 +29,10 @@
import { QRAuthContext } from './qr-auth-context.js';
import { commCoreModule } from '../../native-modules.js';
+import {
+ SecondaryDeviceConnectedRouteName,
+ SecondaryDeviceNotRespondingRouteName,
+} from '../../navigation/route-names.js';
import { useSelector } from '../../redux/redux-utils.js';
import Alert from '../../utils/alert.js';
import {
@@ -36,6 +40,8 @@
parseTunnelbrokerQRAuthMessage,
} from '../../utils/qr-code-utils.js';
+const secondaryDeviceTimeout = 30 * 1000;
+
type Props = {
+children: React.Node,
};
@@ -44,10 +50,11 @@
const secondaryDeviceID = React.useRef<?string>(null);
const secondaryDeviceType = React.useRef<?IdentityDeviceType>(null);
const [connectingInProgress, setConnectingInProgress] = React.useState(false);
+ const timeout = React.useRef<?TimeoutID>(null);
const ownPeerDevices = useSelector(getOwnPeerDevices);
const keyserverDeviceID = getKeyserverDeviceID(ownPeerDevices);
- const { goBack } = useNavigation();
+ const { goBack, navigate } = useNavigation();
const runDeviceListUpdate = useDeviceListUpdate();
const { addListener, removeListener, sendMessageToDevice } =
useTunnelbroker();
@@ -95,12 +102,11 @@
}
setConnectingInProgress(false);
-
- Alert.alert('Device added', 'Device registered successfully', [
- { text: 'OK', onPress: goBack },
- ]);
+ clearTimeout(timeout.current);
+ timeout.current = null;
+ navigate(SecondaryDeviceConnectedRouteName);
},
- [goBack, connectingInProgress],
+ [connectingInProgress, navigate],
);
React.useEffect(() => {
@@ -141,6 +147,10 @@
deviceID: targetDeviceID,
payload: JSON.stringify(message),
});
+ timeout.current = setTimeout(() => {
+ setConnectingInProgress(false);
+ navigate(SecondaryDeviceNotRespondingRouteName);
+ }, secondaryDeviceTimeout);
};
const handleReplaceDevice = async () => {
@@ -206,6 +216,7 @@
goBack,
identityContext,
keyserverDeviceID,
+ navigate,
runDeviceListUpdate,
sendMessageToDevice,
]);

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 12:47 AM (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697620
Default Alt Text
D14153.id46390.diff (2 KB)

Event Timeline