Page MenuHomePhabricator

D12239.id40752.diff
No OneTemporary

D12239.id40752.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
@@ -193,10 +193,35 @@
await updateDeviceList(signedDeviceList);
}
+async function removeDeviceFromDeviceList(
+ identityClient: IdentityServiceClient,
+ userID: string,
+ deviceIDToRemove: string,
+): Promise<void> {
+ const { updateDeviceList } = identityClient;
+ invariant(
+ updateDeviceList,
+ 'updateDeviceList() should be defined on native. ' +
+ 'Are you calling it on a non-primary device?',
+ );
+
+ const { devices } = await fetchLatestDeviceList(identityClient, userID);
+ const newDevices = devices.filter(it => it !== deviceIDToRemove);
+ if (devices.length === newDevices.length) {
+ // the device wasn't on the device list
+ return;
+ }
+
+ const newDeviceList = composeRawDeviceList(newDevices);
+ const signedDeviceList = await signDeviceListUpdate(newDeviceList);
+ await updateDeviceList(signedDeviceList);
+}
+
export {
verifyAndGetDeviceList,
createAndSignInitialDeviceList,
fetchLatestDeviceList,
addDeviceToDeviceList,
+ removeDeviceFromDeviceList,
signDeviceListUpdate,
};

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 5:01 AM (21 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599647
Default Alt Text
D12239.id40752.diff (1 KB)

Event Timeline