mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Fix issue when WebSocket is closed
This commit is contained in:
parent
c5d1512375
commit
e399f71a78
@ -36,7 +36,10 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
super.listen<InvalidLoginTokensEvent>((ev) => _openLoginPage());
|
super.listen<InvalidLoginTokensEvent>((ev) => _openLoginPage());
|
||||||
|
|
||||||
// Listen to WebSocket close event
|
// Listen to WebSocket close event
|
||||||
super.listen<WSClosedEvent>((e) => _tryConnect());
|
super.listen<WSClosedEvent>((e) {
|
||||||
|
_popToMainRoute();
|
||||||
|
_tryConnect();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -65,9 +68,7 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
print("Could not connect to server! $e");
|
print("Could not connect to server! $e");
|
||||||
print(stack);
|
print(stack);
|
||||||
|
|
||||||
// Pop until we reach main route
|
_popToMainRoute();
|
||||||
Navigator.of(context).popUntil((settings) =>
|
|
||||||
ModalRoute.of(context).isCurrent || !ModalRoute.of(context).isActive);
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_error = true;
|
_error = true;
|
||||||
@ -138,4 +139,10 @@ class _InitializeWidgetState extends SafeState<InitializeWidget> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _popToMainRoute() {
|
||||||
|
// Pop until we reach main route
|
||||||
|
Navigator.of(context).popUntil((settings) =>
|
||||||
|
ModalRoute.of(context).isCurrent || !ModalRoute.of(context).isActive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user