From fab16db8b3350f58eb67c6db381cc35c4f7033b4 Mon Sep 17 00:00:00 2001 From: "Aamir.Muhammad" Date: Sun, 20 Nov 2022 15:29:25 +0300 Subject: [PATCH] Chat Updates & Counter Event Modifications --- lib/api/chat/chat_provider_model.dart | 50 ++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index 2e8bcb8..7dbc0be 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -29,7 +29,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { late HubConnection hubConnection; L.Logger logger = L.Logger(); bool hubConInitialized = false; - + String chatCID = ''; bool isLoading = true; bool isChatScreenActive = false; late File selectedFile; @@ -40,17 +40,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { List favUsersList = []; int paginationVal = 0; - //Scroll - bool _firstAutoscrollExecuted = false; - bool _shouldAutoscroll = false; - Future getUserAutoLoginToken(BuildContext cxt) async { Response response = await ApiClient().postJsonForResponse( "${ApiConsts.chatServerBaseApiUrl}user/externaluserlogin", { - "employeeNumber": int.parse( + "employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(), - ), "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG" }, ); @@ -173,6 +168,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { userChatHistory, receiverUID, ); + generateConvId(); + } + + void generateConvId() async { + Uuid uuid = const Uuid(); + chatCID = uuid.v4(); } void markRead(List data, reciverID) { @@ -506,13 +507,14 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { Future sendChatToServer( {required int chatEventId, required fileTypeId, required int targetUserId, required String targetUserName, required chatReplyId, required bool isAttachment, required bool isReply}) async { Uuid uuid = const Uuid(); + var msg = message.text; SingleUserChatModel data = SingleUserChatModel( chatEventId: chatEventId, chatSource: 1, contant: msg, contantNo: uuid.v4(), - conversationId: uuid.v4(), + conversationId: chatCID, createdDate: DateTime.now(), currentUserId: AppState().chatDetails!.response!.id, currentUserName: AppState().chatDetails!.response!.userName, @@ -743,22 +745,22 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { sFileType = ""; } - void scrollListener() { - _firstAutoscrollExecuted = true; - if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) { - _shouldAutoscroll = true; - } else { - _shouldAutoscroll = false; - } - } - - void scrollToBottom() { - scrollController.animateTo( - scrollController.position.maxScrollExtent + 100, - duration: const Duration(milliseconds: 500), - curve: Curves.easeIn, - ); - } + // void scrollListener() { + // _firstAutoscrollExecuted = true; + // if (scrollController.hasClients && scrollController.position.pixels == scrollController.position.maxScrollExtent) { + // _shouldAutoscroll = true; + // } else { + // _shouldAutoscroll = false; + // } + // } + // + // void scrollToBottom() { + // scrollController.animateTo( + // scrollController.position.maxScrollExtent + 100, + // duration: const Duration(milliseconds: 500), + // curve: Curves.easeIn, + // ); + // } void msgScroll() { scrollController.animateTo(