Page MenuHomePhabricator

D13972.id45894.diff
No OneTemporary

D13972.id45894.diff

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

Mime Type
text/plain
Expires
Mon, Dec 23, 12:25 AM (11 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692978
Default Alt Text
D13972.id45894.diff (2 KB)

Event Timeline