Merge branch 'nico/ssss-flakiness' into 'main'
fix: Always wait for account data to load before returning SSSS status See merge request famedly/company/frontend/famedlysdk!1287
This commit is contained in:
		
						commit
						768e2ccc86
					
				|  | @ -61,6 +61,7 @@ class CrossSigning { | ||||||
|       encryption.ssss.isSecret(EventTypes.CrossSigningMasterKey); |       encryption.ssss.isSecret(EventTypes.CrossSigningMasterKey); | ||||||
| 
 | 
 | ||||||
|   Future<bool> isCached() async { |   Future<bool> isCached() async { | ||||||
|  |     await client.accountDataLoading; | ||||||
|     if (!enabled) { |     if (!enabled) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -603,10 +603,10 @@ class KeyManager { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   Future<bool> isCached() async { |   Future<bool> isCached() async { | ||||||
|  |     await client.accountDataLoading; | ||||||
|     if (!enabled) { |     if (!enabled) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|     await client.accountDataLoading; |  | ||||||
|     await client.userDeviceKeysLoading; |     await client.userDeviceKeysLoading; | ||||||
|     return (await encryption.ssss.getCached(megolmKey)) != null; |     return (await encryption.ssss.getCached(megolmKey)) != null; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -292,14 +292,16 @@ class SSSS { | ||||||
|     if (keys == null) { |     if (keys == null) { | ||||||
|       return null; |       return null; | ||||||
|     } |     } | ||||||
|     bool isValid(dbEntry) => |     bool isValid(SSSSCache dbEntry) => | ||||||
|         keys.contains(dbEntry.keyId) && |         keys.contains(dbEntry.keyId) && | ||||||
|         dbEntry.ciphertext != null && |         dbEntry.ciphertext != null && | ||||||
|         client.accountData[type]?.content['encrypted'][dbEntry.keyId] |         client.accountData[type]?.content['encrypted'][dbEntry.keyId] | ||||||
|                 ['ciphertext'] == |                 ['ciphertext'] == | ||||||
|             dbEntry.ciphertext; |             dbEntry.ciphertext; | ||||||
|     if (_cache.containsKey(type) && isValid(_cache[type])) { | 
 | ||||||
|       return _cache[type]?.content; |     final fromCache = _cache[type]; | ||||||
|  |     if (fromCache != null && isValid(fromCache)) { | ||||||
|  |       return fromCache.content; | ||||||
|     } |     } | ||||||
|     final ret = await client.database?.getSSSSCache(type); |     final ret = await client.database?.getSSSSCache(type); | ||||||
|     if (ret == null) { |     if (ret == null) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue