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 @@ -57,6 +57,9 @@ const tunnelbrokerMessageListener = React.useCallback( async (message: TunnelbrokerToDeviceMessage) => { + if (!connectingInProgress) { + return; + } const encryptionKey = aes256Key.current; const targetDeviceID = secondaryDeviceID.current; if (!encryptionKey || !targetDeviceID) { @@ -97,7 +100,7 @@ { text: 'OK', onPress: goBack }, ]); }, - [goBack], + [goBack, connectingInProgress], ); React.useEffect(() => { @@ -241,12 +244,25 @@ [processDeviceListUpdate], ); + const onRemoveSecondaryDevice = React.useCallback(async () => { + if (!secondaryDeviceID.current) { + console.log('No secondary device to remove'); + return; + } + + await runDeviceListUpdate({ + type: 'remove', + deviceID: secondaryDeviceID.current, + }); + }, [runDeviceListUpdate]); + const contextValue = React.useMemo( () => ({ onConnect, connectingInProgress, + onRemoveSecondaryDevice, }), - [onConnect, connectingInProgress], + [onConnect, connectingInProgress, onRemoveSecondaryDevice], ); return ( diff --git a/native/account/qr-auth/qr-auth-context.js b/native/account/qr-auth/qr-auth-context.js --- a/native/account/qr-auth/qr-auth-context.js +++ b/native/account/qr-auth/qr-auth-context.js @@ -5,6 +5,7 @@ export type QRAuthContextType = { +onConnect: (data: string) => Promise, +connectingInProgress: boolean, + +onRemoveSecondaryDevice: () => Promise, }; const QRAuthContext: React.Context =