Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3328583
D13972.id.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
D13972.id.diff
View Options
diff --git a/lib/shared/device-list-utils.js b/lib/shared/device-list-utils.js
--- a/lib/shared/device-list-utils.js
+++ b/lib/shared/device-list-utils.js
@@ -8,10 +8,7 @@
useBroadcastDeviceListUpdates,
useGetAndUpdateDeviceListsForUsers,
} from '../hooks/peer-list-hooks.js';
-import {
- getAllPeerDevices,
- getForeignPeerDeviceIDs,
-} from '../selectors/user-selectors.js';
+import { getForeignPeerDeviceIDs } from '../selectors/user-selectors.js';
import type {
IdentityServiceClient,
RawDeviceList,
@@ -206,7 +203,7 @@
identityClient: IdentityServiceClient,
userID: string,
deviceIDToRemove: string,
-): Promise<void> {
+): Promise<?SignedDeviceList> {
const { updateDeviceList } = identityClient;
invariant(
updateDeviceList,
@@ -218,12 +215,13 @@
const newDevices = devices.filter(it => it !== deviceIDToRemove);
if (devices.length === newDevices.length) {
// the device wasn't on the device list
- return;
+ return null;
}
const newDeviceList = composeRawDeviceList(newDevices);
const signedDeviceList = await signDeviceListUpdate(newDeviceList);
await updateDeviceList(signedDeviceList);
+ return signedDeviceList;
}
async function replaceDeviceInDeviceList(
@@ -276,7 +274,6 @@
invariant(identityContext, 'identity context not set');
const { identityClient, getAuthMetadata } = identityContext;
- const allPeerDevices = useSelector(getAllPeerDevices);
const foreignPeerDevices = useSelector(getForeignPeerDeviceIDs);
const broadcastDeviceListUpdates = useBroadcastDeviceListUpdates();
const getAndUpdateDeviceListsForUsers = useGetAndUpdateDeviceListsForUsers();
@@ -345,25 +342,21 @@
await sendDeviceListUpdates(signedDeviceList, userID, primaryDeviceID);
} else if (update.type === 'remove') {
const { deviceID } = update;
- const { userID } = await getAuthMetadata();
+ const { userID, deviceID: primaryDeviceID } = await getAuthMetadata();
- if (!userID) {
+ if (!userID || !primaryDeviceID) {
throw new Error('missing auth metadata');
}
- await removeDeviceFromDeviceList(identityClient, userID, deviceID);
- await broadcastDeviceListUpdates(
- allPeerDevices.filter(it => it !== deviceID),
+ const signedDeviceList = await removeDeviceFromDeviceList(
+ identityClient,
+ userID,
+ deviceID,
);
+ await sendDeviceListUpdates(signedDeviceList, userID, primaryDeviceID);
}
},
- [
- allPeerDevices,
- broadcastDeviceListUpdates,
- getAuthMetadata,
- identityClient,
- sendDeviceListUpdates,
- ],
+ [getAuthMetadata, identityClient, sendDeviceListUpdates],
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 2:06 PM (13 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2556310
Default Alt Text
D13972.id.diff (2 KB)
Attached To
Mode
D13972: [lib] standarize broadcasting device list update when removing device
Attached
Detach File
Event Timeline
Log In to Comment