Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3513986
D14153.id46553.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D14153.id46553.diff
View Options
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();
@@ -55,6 +62,14 @@
const identityContext = React.useContext(IdentityClientContext);
invariant(identityContext, 'identity context not set');
+ React.useEffect(() => {
+ return () => {
+ if (timeout.current) {
+ clearTimeout(timeout.current);
+ }
+ };
+ }, []);
+
const tunnelbrokerMessageListener = React.useCallback(
async (message: TunnelbrokerToDeviceMessage) => {
if (!connectingInProgress) {
@@ -95,12 +110,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 +155,10 @@
deviceID: targetDeviceID,
payload: JSON.stringify(message),
});
+ timeout.current = setTimeout(() => {
+ setConnectingInProgress(false);
+ navigate(SecondaryDeviceNotRespondingRouteName);
+ }, secondaryDeviceTimeout);
};
const handleReplaceDevice = async () => {
@@ -206,6 +224,7 @@
goBack,
identityContext,
keyserverDeviceID,
+ navigate,
runDeviceListUpdate,
sendMessageToDevice,
]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 2:59 AM (6 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693307
Default Alt Text
D14153.id46553.diff (2 KB)
Attached To
Mode
D14153: [native] handle waiting for secondary device response
Attached
Detach File
Event Timeline
Log In to Comment