Update Account#getNextDeviceId to not reuse disable device’s IDs

This commit is contained in:
Chris Eager authored and Chris Eager committed 2021-09-10 10:48:48 -07:00
1 parent 016141a05d
commit 23a076a204
2 files changed
+31 -8

No files matched your search

@@ -212,17 +212,13 @@ public class Account {
public long getNextDeviceId() {
requireNotStale();
long highestDevice = Device.MASTER_ID;
long candidateId = Device.MASTER_ID + 1;
for (Device device : devices) {
if (!device.isEnabled()) {
return device.getId();
} else if (device.getId() > highestDevice) {
highestDevice = device.getId();
}
while (getDevice(candidateId).isPresent()) {
candidateId++;
}
return highestDevice + 1;
return candidateId;
}
public int getEnabledDeviceCount() {