feat: Add waitForFirstSync parameter to init method
Just using the .init() method to wait for the client to initialize is a more easy way than listen to onLoginStateChanged. But by default it waits for the first sync. This should be configurable.
This commit is contained in:
parent
e7de73d3a4
commit
e0e09c2f67
|
|
@ -884,6 +884,7 @@ class Client extends MatrixApi {
|
|||
String newDeviceName,
|
||||
String newDeviceID,
|
||||
String newOlmAccount,
|
||||
bool waitForFirstSync = true,
|
||||
}) async {
|
||||
if ((newToken != null ||
|
||||
newUserID != null ||
|
||||
|
|
@ -1002,7 +1003,12 @@ class Client extends MatrixApi {
|
|||
Logs().i(
|
||||
'Successfully connected as ${userID.localpart} with ${homeserver.toString()}',
|
||||
);
|
||||
return _sync();
|
||||
|
||||
final syncFuture = _sync();
|
||||
if (waitForFirstSync) {
|
||||
await syncFuture;
|
||||
}
|
||||
return;
|
||||
} catch (e, s) {
|
||||
Logs().e('Initialization failed', e, s);
|
||||
await logout().catchError((_) => null);
|
||||
|
|
|
|||
Loading…
Reference in New Issue