refactor: make sure ensureNotSoftLoggedOut does not run multiple times
This commit is contained in:
parent
3f8a4c8189
commit
5a79aa9536
|
|
@ -1823,10 +1823,13 @@ class Client extends MatrixApi {
|
|||
return;
|
||||
}
|
||||
|
||||
Future<void>? _handleSoftLogoutFuture;
|
||||
|
||||
Future<void> _handleSoftLogout() async {
|
||||
final onSoftLogout = this.onSoftLogout;
|
||||
if (onSoftLogout == null) return;
|
||||
|
||||
_handleSoftLogoutFuture ??= () async {
|
||||
onLoginStateChanged.add(LoginState.softLoggedOut);
|
||||
try {
|
||||
await onSoftLogout(this);
|
||||
|
|
@ -1836,6 +1839,9 @@ class Client extends MatrixApi {
|
|||
await clear();
|
||||
rethrow;
|
||||
}
|
||||
}();
|
||||
await _handleSoftLogoutFuture;
|
||||
_handleSoftLogoutFuture = null;
|
||||
}
|
||||
|
||||
/// Checks if the token expires in under [expiresIn] time and calls the
|
||||
|
|
|
|||
Loading…
Reference in New Issue