diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index f3747c0..c23765a 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -84,19 +84,22 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { bool disbaleChatForThisUser = false; bool isCall = false; - userLoginToken.UserAutoLoginModel userLoginData = userLoginToken.UserAutoLoginModel(); - Future getUserAutoLoginToken() async { - userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); - if (userLoginResponse.response != null) { - AppState().setchatUserDetails = userLoginResponse; - } else { - AppState().setchatUserDetails = userLoginResponse; - Utils.showToast( - userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr", - ); + try { + userLoginToken.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); + if (userLoginResponse.response != null) { + AppState().setchatUserDetails = userLoginResponse; + } else { + AppState().setchatUserDetails = userLoginResponse; + Utils.showToast( + userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr", + ); + disbaleChatForThisUser = true; + notifyListeners(); + } + } catch (e) { disbaleChatForThisUser = true; notifyListeners(); } @@ -105,7 +108,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future buildHubConnection({required BuildContext context, required ChatCallProvider ccProvider}) async { try { chatHubConnection = await getHubConnection(); - }catch(e){ + } catch (e) { Utils.showToast(e.toString()); } await chatHubConnection.start(); diff --git a/lib/ui/landing/dashboard_screen.dart b/lib/ui/landing/dashboard_screen.dart index b036581..4b1dad8 100644 --- a/lib/ui/landing/dashboard_screen.dart +++ b/lib/ui/landing/dashboard_screen.dart @@ -127,6 +127,7 @@ class _DashboardScreenState extends State with WidgetsBindingOb if (chatHubConnection.state == HubConnectionState.Connected) { Utils.hideLoading(context); Navigator.pushNamed(context, AppRoutes.chat); + Utils.saveStringFromPrefs("isAppOpendByChat", "false"); } }