refactor: Make possible to wait for first sync and await first sync before create megolm session

This commit is contained in:
Krille 2023-12-08 10:46:16 +01:00
parent 94313a0904
commit 55bfc92ee0
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View File

@ -502,6 +502,7 @@ class KeyManager {
Future<OutboundGroupSession> _createOutboundGroupSession( Future<OutboundGroupSession> _createOutboundGroupSession(
String roomId) async { String roomId) async {
await clearOrUseOutboundGroupSession(roomId, wipe: true); await clearOrUseOutboundGroupSession(roomId, wipe: true);
await client.firstSyncReceived;
final room = client.getRoomById(roomId); final room = client.getRoomById(roomId);
if (room == null) { if (room == null) {
throw Exception( throw Exception(

View File

@ -1586,9 +1586,9 @@ class Client extends MatrixApi {
); );
/// Timeout of 0, so that we don't see a spinner for 30 seconds. /// Timeout of 0, so that we don't see a spinner for 30 seconds.
final syncFuture = _sync(timeout: Duration.zero); firstSyncReceived = _sync(timeout: Duration.zero);
if (waitForFirstSync) { if (waitForFirstSync) {
await syncFuture; await firstSyncReceived;
} }
return; return;
} catch (e, s) { } catch (e, s) {
@ -2341,6 +2341,7 @@ class Client extends MatrixApi {
Future? userDeviceKeysLoading; Future? userDeviceKeysLoading;
Future? roomsLoading; Future? roomsLoading;
Future? _accountDataLoading; Future? _accountDataLoading;
Future? firstSyncReceived;
Future? get accountDataLoading => _accountDataLoading; Future? get accountDataLoading => _accountDataLoading;