feat: Minor changes

This commit is contained in:
PapaTutuWawa committed 2023-06-17 23:23:41 +02:00
1 parent b986096aa0
commit c086579b57
3 files changed
+22 -18

No files matched your search

+6 -2
View File
@@ -86,9 +86,13 @@ extension BeforeAfterListDiff<T> on List<T> {
extension AppendToListOrCreateExtension<K, V> on Map<K, List<V>> {
/// Create or append [value] to the list identified with key [key].
void appendOrCreate(K key, V value) {
void appendOrCreate(K key, V value, {bool checkExistence = false}) {
if (containsKey(key)) {
this[key]!.add(value);
if (!checkExistence) {
this[key]!.add(value);
} if (!this[key]!.contains(value)) {
this[key]!.add(value);
}
} else {
this[key] = [value];
}
+3 -6
View File
@@ -132,11 +132,8 @@ class BlindTrustBeforeVerificationTrustManager extends TrustManager {
enablementCache[key] = true;
}
if (devices.containsKey(jid)) {
devices[jid]!.add(deviceId);
} else {
devices[jid] = List<int>.from([deviceId]);
}
// Append to the device list
devices.appendOrCreate(jid, deviceId, checkExistence: true);
// Commit the state
await commit(
@@ -227,7 +224,7 @@ class BlindTrustBeforeVerificationTrustManager extends TrustManager {
final key = RatchetMapKey(jid, result.device);
trustCache[key] = result.state;
enablementCache[key] = result.enabled;
devices.appendOrCreate(jid, result.device);
devices.appendOrCreate(jid, result.device, checkExistence: true);
}
}