mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Fix issue when WebSocket is closed
This commit is contained in:
		@@ -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);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user