Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3386494
D12239.id40752.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12239.id40752.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
@@ -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
Details
Attached
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)
Attached To
Mode
D12239: [lib] Add function to remove device from device list
Attached
Detach File
Event Timeline
Log In to Comment