refactor: Use .toSet() instead of Set.from()
When using Set.from() then it becomes a Set of dynamics which disables the Type checking. By just changing this to .toSet() it keeps the type.
This commit is contained in:
parent
ac77f0e0bb
commit
86038f8c94
|
|
@ -357,8 +357,8 @@ class KeyManager {
|
||||||
final newDeviceKeys = await room.getUserDeviceKeys();
|
final newDeviceKeys = await room.getUserDeviceKeys();
|
||||||
final newDeviceKeyIds = _getDeviceKeyIdMap(newDeviceKeys);
|
final newDeviceKeyIds = _getDeviceKeyIdMap(newDeviceKeys);
|
||||||
// first check for user differences
|
// first check for user differences
|
||||||
final oldUserIds = Set.from(sess.devices.keys);
|
final oldUserIds = sess.devices.keys.toSet();
|
||||||
final newUserIds = Set.from(newDeviceKeyIds.keys);
|
final newUserIds = newDeviceKeyIds.keys.toSet();
|
||||||
if (oldUserIds.difference(newUserIds).isNotEmpty) {
|
if (oldUserIds.difference(newUserIds).isNotEmpty) {
|
||||||
// a user left the room, we must wipe the session
|
// a user left the room, we must wipe the session
|
||||||
wipe = true;
|
wipe = true;
|
||||||
|
|
@ -375,19 +375,17 @@ class KeyManager {
|
||||||
// we also know that all the old user IDs appear in the old one, else we have already wiped the session
|
// we also know that all the old user IDs appear in the old one, else we have already wiped the session
|
||||||
for (final userId in oldUserIds) {
|
for (final userId in oldUserIds) {
|
||||||
final oldBlockedDevices = sess.devices.containsKey(userId)
|
final oldBlockedDevices = sess.devices.containsKey(userId)
|
||||||
? Set.from(
|
? sess.devices[userId]!.entries
|
||||||
sess.devices[userId]!.entries
|
.where((e) => e.value)
|
||||||
.where((e) => e.value)
|
.map((e) => e.key)
|
||||||
.map((e) => e.key),
|
.toSet()
|
||||||
)
|
|
||||||
: <String>{};
|
: <String>{};
|
||||||
final newBlockedDevices = newDeviceKeyIds.containsKey(userId)
|
final newBlockedDevices = newDeviceKeyIds.containsKey(userId)
|
||||||
? Set.from(
|
? newDeviceKeyIds[userId]!
|
||||||
newDeviceKeyIds[userId]!
|
.entries
|
||||||
.entries
|
.where((e) => e.value)
|
||||||
.where((e) => e.value)
|
.map((e) => e.key)
|
||||||
.map((e) => e.key),
|
.toSet()
|
||||||
)
|
|
||||||
: <String>{};
|
: <String>{};
|
||||||
// we don't really care about old devices that got dropped (deleted), we only care if new ones got added and if new ones got blocked
|
// we don't really care about old devices that got dropped (deleted), we only care if new ones got added and if new ones got blocked
|
||||||
// check if new devices got blocked
|
// check if new devices got blocked
|
||||||
|
|
@ -397,19 +395,17 @@ class KeyManager {
|
||||||
}
|
}
|
||||||
// and now add all the new devices!
|
// and now add all the new devices!
|
||||||
final oldDeviceIds = sess.devices.containsKey(userId)
|
final oldDeviceIds = sess.devices.containsKey(userId)
|
||||||
? Set.from(
|
? sess.devices[userId]!.entries
|
||||||
sess.devices[userId]!.entries
|
.where((e) => !e.value)
|
||||||
.where((e) => !e.value)
|
.map((e) => e.key)
|
||||||
.map((e) => e.key),
|
.toSet()
|
||||||
)
|
|
||||||
: <String>{};
|
: <String>{};
|
||||||
final newDeviceIds = newDeviceKeyIds.containsKey(userId)
|
final newDeviceIds = newDeviceKeyIds.containsKey(userId)
|
||||||
? Set.from(
|
? newDeviceKeyIds[userId]!
|
||||||
newDeviceKeyIds[userId]!
|
.entries
|
||||||
.entries
|
.where((e) => !e.value)
|
||||||
.where((e) => !e.value)
|
.map((e) => e.key)
|
||||||
.map((e) => e.key),
|
.toSet()
|
||||||
)
|
|
||||||
: <String>{};
|
: <String>{};
|
||||||
|
|
||||||
// check if a device got removed
|
// check if a device got removed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue