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:
Nicolas Werner 2023-05-04 08:44:27 +00:00
commit 768e2ccc86
3 changed files with 7 additions and 4 deletions

View File

@ -61,6 +61,7 @@ class CrossSigning {
encryption.ssss.isSecret(EventTypes.CrossSigningMasterKey);
Future<bool> isCached() async {
await client.accountDataLoading;
if (!enabled) {
return false;
}

View File

@ -603,10 +603,10 @@ class KeyManager {
}
Future<bool> isCached() async {
await client.accountDataLoading;
if (!enabled) {
return false;
}
await client.accountDataLoading;
await client.userDeviceKeysLoading;
return (await encryption.ssss.getCached(megolmKey)) != null;
}

View File

@ -292,14 +292,16 @@ class SSSS {
if (keys == null) {
return null;
}
bool isValid(dbEntry) =>
bool isValid(SSSSCache dbEntry) =>
keys.contains(dbEntry.keyId) &&
dbEntry.ciphertext != null &&
client.accountData[type]?.content['encrypted'][dbEntry.keyId]
['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);
if (ret == null) {