Page MenuHomePhabricator

D12430.diff
No OneTemporary

D12430.diff

diff --git a/native/profile/secondary-device-qr-code-scanner.react.js b/native/profile/secondary-device-qr-code-scanner.react.js
--- a/native/profile/secondary-device-qr-code-scanner.react.js
+++ b/native/profile/secondary-device-qr-code-scanner.react.js
@@ -7,7 +7,11 @@
import { View } from 'react-native';
import { parseDataFromDeepLink } from 'lib/facts/links.js';
-import { useBroadcastDeviceListUpdates } from 'lib/hooks/peer-list-hooks.js';
+import {
+ useBroadcastDeviceListUpdates,
+ useGetAndUpdateDeviceListsForUsers,
+} from 'lib/hooks/peer-list-hooks.js';
+import { getForeignPeerDevices } from 'lib/selectors/user-selectors.js';
import { addDeviceToDeviceList } from 'lib/shared/device-list-utils.js';
import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import { useTunnelbroker } from 'lib/tunnelbroker/tunnelbroker-context.js';
@@ -36,6 +40,7 @@
composeTunnelbrokerQRAuthMessage,
parseTunnelbrokerQRAuthMessage,
} from '../qr-code/qr-code-utils.js';
+import { useSelector } from '../redux/redux-utils.js';
import { useStyles } from '../themes/colors.js';
import Alert from '../utils/alert.js';
@@ -61,6 +66,9 @@
const secondaryDeviceID = React.useRef<?string>(null);
const broadcastDeviceListUpdates = useBroadcastDeviceListUpdates();
+ const getAndUpdateDeviceListsForUsers = useGetAndUpdateDeviceListsForUsers();
+
+ const foreignPeerDevices = useSelector(getForeignPeerDevices);
const tunnelbrokerMessageListener = React.useCallback(
async (message: TunnelbrokerMessage) => {
@@ -100,8 +108,8 @@
invariant(identityContext, 'identity context not set');
const { getAuthMetadata, identityClient } = identityContext;
- const { userID } = await getAuthMetadata();
- if (!userID) {
+ const { userID, deviceID } = await getAuthMetadata();
+ if (!userID || !deviceID) {
throw new Error('missing auth metadata');
}
@@ -112,10 +120,15 @@
const lastSignedDeviceList = deviceLists[deviceLists.length - 1];
const deviceList = rawDeviceListFromSignedList(lastSignedDeviceList);
- await broadcastDeviceListUpdates(
- deviceList.devices,
- lastSignedDeviceList,
- );
+ const ownOtherDevices = deviceList.devices.filter(it => it !== deviceID);
+
+ await Promise.all([
+ broadcastDeviceListUpdates(
+ [...ownOtherDevices, ...foreignPeerDevices],
+ lastSignedDeviceList,
+ ),
+ getAndUpdateDeviceListsForUsers([userID]),
+ ]);
if (!payload.requestBackupKeys) {
Alert.alert('Device added', 'Device registered successfully', [
@@ -148,7 +161,13 @@
{ text: 'OK' },
]);
},
- [identityContext, broadcastDeviceListUpdates, tunnelbrokerContext],
+ [
+ identityContext,
+ broadcastDeviceListUpdates,
+ foreignPeerDevices,
+ getAndUpdateDeviceListsForUsers,
+ tunnelbrokerContext,
+ ],
);
React.useEffect(() => {

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 9:50 PM (20 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581078
Default Alt Text
D12430.diff (2 KB)

Event Timeline