Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3362231
D12430.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
D12430.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D12430: [lib] broadcast updates to all peers after Secondary Device registration success
Attached
Detach File
Event Timeline
Log In to Comment