Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32222234
D13972.1765202006.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D13972.1765202006.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
Mon, Dec 8, 1:53 PM (6 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5848588
Default Alt Text
D13972.1765202006.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