Merge pull request #3804 from vector-im/feature/ons/fix_deleting_user_device
Fix error when sending encrypted message if someone in the room logs out
This commit is contained in:
commit
60a210194d
|
@ -0,0 +1 @@
|
||||||
|
Fix error when sending encrypted message if someone in the room logs out.
|
|
@ -286,10 +286,13 @@ internal class RealmCryptoStore @Inject constructor(
|
||||||
val userEntity = UserEntity.getOrCreate(realm, userId)
|
val userEntity = UserEntity.getOrCreate(realm, userId)
|
||||||
// First delete the removed devices
|
// First delete the removed devices
|
||||||
val deviceIds = devices.keys
|
val deviceIds = devices.keys
|
||||||
userEntity.devices.iterator().forEach { deviceInfoEntity ->
|
userEntity.devices.toTypedArray().iterator().let {
|
||||||
if (deviceInfoEntity.deviceId !in deviceIds) {
|
while (it.hasNext()) {
|
||||||
Timber.d("Remove device ${deviceInfoEntity.deviceId} of user $userId")
|
val deviceInfoEntity = it.next()
|
||||||
deviceInfoEntity.deleteOnCascade()
|
if (deviceInfoEntity.deviceId !in deviceIds) {
|
||||||
|
Timber.d("Remove device ${deviceInfoEntity.deviceId} of user $userId")
|
||||||
|
deviceInfoEntity.deleteOnCascade()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Then update existing devices or add new one
|
// Then update existing devices or add new one
|
||||||
|
|
Loading…
Reference in New Issue