From 2266ace39a6f5331b137253557eca257a9e56847 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Wed, 14 Dec 2022 10:23:21 +0300 Subject: [PATCH] Chat Fixes & Call Button Disabled --- lib/api/chat/chat_api_client.dart | 30 --------------------------- lib/provider/chat_provider_model.dart | 11 +++++----- lib/ui/chat/chat_detailed_screen.dart | 16 +++++++------- 3 files changed, 14 insertions(+), 43 deletions(-) diff --git a/lib/api/chat/chat_api_client.dart b/lib/api/chat/chat_api_client.dart index 3ef8fba..35e4f79 100644 --- a/lib/api/chat/chat_api_client.dart +++ b/lib/api/chat/chat_api_client.dart @@ -60,17 +60,6 @@ class ChatApiClient { json.decode(response.body), ); } catch (e) { - // if (e.message == "api_common_unauthorized") { - // user.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); - // if (userLoginResponse.response != null) { - // AppState().setchatUserDetails = userLoginResponse; - // getRecentChats(); - // } else { - // Utils.showToast( - // userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr", - // ); - // } - // } throw e; } } @@ -97,16 +86,6 @@ class ChatApiClient { } return response; } catch (e) { - // e as APIException; - // if (e.message == "api_common_unauthorized") { - // user.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); - // if (userLoginResponse.response != null) { - // AppState().setchatUserDetails = userLoginResponse; - // getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal); - // } else { - // Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr"); - // } - // } throw e; } } @@ -135,15 +114,6 @@ class ChatApiClient { return favoriteChatUser; } catch (e) { e as APIException; - // if (e.message == "api_common_unauthorized") { - // user.UserAutoLoginModel userLoginResponse = await ChatApiClient().getUserLoginToken(); - // if (userLoginResponse.response != null) { - // AppState().setchatUserDetails = userLoginResponse; - // unFavUser(userID: userID, targetUserID: targetUserID); - // } else { - // Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr"); - // } - // } throw e; } } diff --git a/lib/provider/chat_provider_model.dart b/lib/provider/chat_provider_model.dart index 3f76a86..fbcb801 100644 --- a/lib/provider/chat_provider_model.dart +++ b/lib/provider/chat_provider_model.dart @@ -36,6 +36,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { String chatCID = ''; bool isLoading = true; bool isChatScreenActive = false; + int ReceiverID = 0; + late File selectedFile; bool isFileSelected = false; String sFileType = ""; @@ -142,6 +144,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { if (isNewChat) userChatHistory = []; if (!loadMore) paginationVal = 0; isChatScreenActive = true; + ReceiverID = receiverUID; Response response = await ChatApiClient().getSingleUserChatHistory(senderUID: senderUID, receiverUID: receiverUID, loadMore: loadMore, paginationVal: paginationVal); if (response.statusCode == 204) { if (isNewChat) { @@ -371,13 +374,11 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } setMsgTune(); - if (isChatScreenActive) { - if (data.first.targetUserId == AppState().chatDetails!.response!.id) { - userChatHistory.insert(0, data.first); - } + if (isChatScreenActive && data.first.currentUserId == ReceiverID) { + userChatHistory.insert(0, data.first); } - if (searchedChats != null && !isChatScreenActive) { + if (searchedChats != null) { for (ChatUser user in searchedChats!) { if (user.id == data.first.currentUserId) { int tempCount = user.unreadMessageCount ?? 0; diff --git a/lib/ui/chat/chat_detailed_screen.dart b/lib/ui/chat/chat_detailed_screen.dart index be685df..5cad3fa 100644 --- a/lib/ui/chat/chat_detailed_screen.dart +++ b/lib/ui/chat/chat_detailed_screen.dart @@ -85,14 +85,14 @@ class _ChatDetailScreenState extends State { showTyping: true, chatUser: params!.chatUser, actions: [ - SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() { - // makeCall(callType: "AUDIO", con: hubConnection); - }), - 24.width, - SvgPicture.asset("assets/icons/chat/video_call.svg", width: 21, height: 18).onPress(() { - // makeCall(callType: "VIDEO", con: hubConnection); - }), - 21.width, + // SvgPicture.asset("assets/icons/chat/call.svg", width: 21, height: 23).onPress(() { + // // makeCall(callType: "AUDIO", con: hubConnection); + // }), + // 24.width, + // SvgPicture.asset("assets/icons/chat/video_call.svg", width: 21, height: 18).onPress(() { + // // makeCall(callType: "VIDEO", con: hubConnection); + // }), + // 21.width, ], ), body: SafeArea(