refactor: simplify device_keys_list.dart
This commit is contained in:
		
							parent
							
								
									a196b53219
								
							
						
					
					
						commit
						da80658c09
					
				|  | @ -37,15 +37,7 @@ class DeviceKeysList { | ||||||
|   Map<String, DeviceKeys> deviceKeys = {}; |   Map<String, DeviceKeys> deviceKeys = {}; | ||||||
|   Map<String, CrossSigningKey> crossSigningKeys = {}; |   Map<String, CrossSigningKey> crossSigningKeys = {}; | ||||||
| 
 | 
 | ||||||
|   SignableKey? getKey(String id) { |   SignableKey? getKey(String id) => deviceKeys[id] ?? crossSigningKeys[id]; | ||||||
|     if (deviceKeys.containsKey(id)) { |  | ||||||
|       return deviceKeys[id]; |  | ||||||
|     } |  | ||||||
|     if (crossSigningKeys.containsKey(id)) { |  | ||||||
|       return crossSigningKeys[id]; |  | ||||||
|     } |  | ||||||
|     return null; |  | ||||||
|   } |  | ||||||
| 
 | 
 | ||||||
|   CrossSigningKey? getCrossSigningKey(String type) => |   CrossSigningKey? getCrossSigningKey(String type) => | ||||||
|       crossSigningKeys.values.firstWhereOrNull((k) => k.usage.contains(type)); |       crossSigningKeys.values.firstWhereOrNull((k) => k.usage.contains(type)); | ||||||
|  | @ -176,8 +168,7 @@ abstract class SignableKey extends MatrixSignableKey { | ||||||
|   SimpleSignableKey cloneForSigning() { |   SimpleSignableKey cloneForSigning() { | ||||||
|     final newKey = SimpleSignableKey.fromJson(toJson().copy()); |     final newKey = SimpleSignableKey.fromJson(toJson().copy()); | ||||||
|     newKey.identifier = identifier; |     newKey.identifier = identifier; | ||||||
|     newKey.signatures ??= <String, Map<String, String>>{}; |     (newKey.signatures ??= {}).clear(); | ||||||
|     newKey.signatures!.clear(); |  | ||||||
|     return newKey; |     return newKey; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | @ -426,8 +417,7 @@ class DeviceKeys extends SignableKey { | ||||||
|   late DateTime lastActive; |   late DateTime lastActive; | ||||||
| 
 | 
 | ||||||
|   String? get curve25519Key => keys['curve25519:$deviceId']; |   String? get curve25519Key => keys['curve25519:$deviceId']; | ||||||
|   String? get deviceDisplayName => |   String? get deviceDisplayName => unsigned?['device_display_name']; | ||||||
|       unsigned != null ? unsigned!['device_display_name'] : null; |  | ||||||
| 
 | 
 | ||||||
|   bool? _validSelfSignature; |   bool? _validSelfSignature; | ||||||
|   bool get selfSigned => |   bool get selfSigned => | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue