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 newDeviceName,
|
||||||
String newDeviceID,
|
String newDeviceID,
|
||||||
String newOlmAccount,
|
String newOlmAccount,
|
||||||
|
bool waitForFirstSync = true,
|
||||||
}) async {
|
}) async {
|
||||||
if ((newToken != null ||
|
if ((newToken != null ||
|
||||||
newUserID != null ||
|
newUserID != null ||
|
||||||
|
|
@ -1002,7 +1003,12 @@ class Client extends MatrixApi {
|
||||||
Logs().i(
|
Logs().i(
|
||||||
'Successfully connected as ${userID.localpart} with ${homeserver.toString()}',
|
'Successfully connected as ${userID.localpart} with ${homeserver.toString()}',
|
||||||
);
|
);
|
||||||
return _sync();
|
|
||||||
|
final syncFuture = _sync();
|
||||||
|
if (waitForFirstSync) {
|
||||||
|
await syncFuture;
|
||||||
|
}
|
||||||
|
return;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logs().e('Initialization failed', e, s);
|
Logs().e('Initialization failed', e, s);
|
||||||
await logout().catchError((_) => null);
|
await logout().catchError((_) => null);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue