diff --git a/lib/providers/account.dart b/lib/providers/account.dart index eb7394c..978e590 100644 --- a/lib/providers/account.dart +++ b/lib/providers/account.dart @@ -36,6 +36,8 @@ class AccountProvider extends GetxController { } void connect({noRetry = false}) async { + if (isConnected.value) return; + final AuthProvider auth = Get.find(); if (!await auth.isAuthorized) throw Exception('unauthorized'); @@ -66,6 +68,7 @@ class AccountProvider extends GetxController { void disconnect() { websocket?.sink.close(WebSocketStatus.normalClosure); + websocket = null; isConnected.value = false; } diff --git a/lib/providers/chat.dart b/lib/providers/chat.dart index 2e3fa18..970f193 100644 --- a/lib/providers/chat.dart +++ b/lib/providers/chat.dart @@ -17,6 +17,8 @@ class ChatProvider extends GetxController { StreamController stream = StreamController.broadcast(); void connect({noRetry = false}) async { + if (isConnected.value) return; + final AuthProvider auth = Get.find(); if (!await auth.isAuthorized) throw Exception('unauthorized'); @@ -47,6 +49,7 @@ class ChatProvider extends GetxController { void disconnect() { websocket?.sink.close(WebSocketStatus.normalClosure); + websocket = null; isConnected.value = false; }