|  |  |  | @ -7,6 +7,7 @@ import 'package:flutter/cupertino.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:flutter/foundation.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:http/http.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:logger/logger.dart' as L; | 
		
	
		
			
				|  |  |  |  | import 'package:logging/logging.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/api/api_client.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/app_state/app_state.dart'; | 
		
	
		
			
				|  |  |  |  | import 'package:mohem_flutter_app/classes/consts.dart'; | 
		
	
	
		
			
				
					|  |  |  | @ -27,6 +28,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   List<ChatUser>? pChatHistory, searchedChats; | 
		
	
		
			
				|  |  |  |  |   late HubConnection hubConnection; | 
		
	
		
			
				|  |  |  |  |   L.Logger logger = L.Logger(); | 
		
	
		
			
				|  |  |  |  |   bool hubConInitialized = false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   bool isLoading = true; | 
		
	
		
			
				|  |  |  |  |   bool isChatScreenActive = false; | 
		
	
	
		
			
				
					|  |  |  | @ -43,13 +45,27 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |   bool _shouldAutoscroll = false; | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<void> getUserAutoLoginToken() async { | 
		
	
		
			
				|  |  |  |  |     String userName = AppState().memberInformationList!.eMPLOYEEEMAILADDRESS!.split("@").first.toString(); | 
		
	
		
			
				|  |  |  |  |     //userName | 
		
	
		
			
				|  |  |  |  |     Response response = | 
		
	
		
			
				|  |  |  |  |         await ApiClient().postJsonForResponse("${ApiConsts.chatServerBaseApiUrl}user/desktopuserlogin", {"userName": userName, "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG", "loginType": 2}); | 
		
	
		
			
				|  |  |  |  |     login.UserAutoLoginModel userLoginResponse = login.userAutoLoginModelFromJson(response.body); | 
		
	
		
			
				|  |  |  |  |     Response response = await ApiClient().postJsonForResponse( | 
		
	
		
			
				|  |  |  |  |       "${ApiConsts.chatServerBaseApiUrl}user/externaluserlogin", | 
		
	
		
			
				|  |  |  |  |       { | 
		
	
		
			
				|  |  |  |  |         "employeeNumber": int.parse( | 
		
	
		
			
				|  |  |  |  |           AppState().memberInformationList!.eMPLOYEENUMBER.toString(), | 
		
	
		
			
				|  |  |  |  |         ), | 
		
	
		
			
				|  |  |  |  |         "password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG" | 
		
	
		
			
				|  |  |  |  |       }, | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  |     login.UserAutoLoginModel userLoginResponse = login.userAutoLoginModelFromJson( | 
		
	
		
			
				|  |  |  |  |       response.body, | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     if (userLoginResponse.response != null) { | 
		
	
		
			
				|  |  |  |  |       hubConInitialized = true; | 
		
	
		
			
				|  |  |  |  |       AppState().setchatUserDetails = userLoginResponse; | 
		
	
		
			
				|  |  |  |  |       await buildHubConnection(); | 
		
	
		
			
				|  |  |  |  |     } else { | 
		
	
		
			
				|  |  |  |  |       Utils.showToast(userLoginResponse.errorResponses!.first.fieldName.toString() + " Erorr"); | 
		
	
		
			
				|  |  |  |  |       return; | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   Future<List<ChatUser>?> getChatMemberFromSearch(String sName, int cUserId) async { | 
		
	
	
		
			
				
					|  |  |  | @ -95,6 +111,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false}) async { | 
		
	
		
			
				|  |  |  |  |     isLoading = true; | 
		
	
		
			
				|  |  |  |  |     if (isNewChat) userChatHistory = []; | 
		
	
		
			
				|  |  |  |  |     if (!loadMore) paginationVal = 0; | 
		
	
		
			
				|  |  |  |  |     isChatScreenActive = true; | 
		
	
		
			
				|  |  |  |  |     Response response = await ApiClient().getJsonForResponse( | 
		
	
	
		
			
				
					|  |  |  | @ -152,7 +169,9 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |         .withUrl(ApiConsts.chatHubConnectionUrl + "?UserId=${AppState().chatDetails!.response!.id}&source=Web&access_token=${AppState().chatDetails!.response!.token}", options: httpOp) | 
		
	
		
			
				|  |  |  |  |         .withAutomaticReconnect( | 
		
	
		
			
				|  |  |  |  |           retryDelays: <int>[2000, 5000, 10000, 20000], | 
		
	
		
			
				|  |  |  |  |     ).build(); | 
		
	
		
			
				|  |  |  |  |         ) | 
		
	
		
			
				|  |  |  |  |         .configureLogging(Logger("Loggin")) | 
		
	
		
			
				|  |  |  |  |         .build(); | 
		
	
		
			
				|  |  |  |  |     hubConnection.onclose( | 
		
	
		
			
				|  |  |  |  |       ({Exception? error}) {}, | 
		
	
		
			
				|  |  |  |  |     ); | 
		
	
	
		
			
				
					|  |  |  | @ -173,6 +192,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  |       hubConnection.on("OnUpdateUserChatHistoryWindowsAsync", updateChatHistoryWindow); | 
		
	
		
			
				|  |  |  |  |       hubConnection.on("OnGetUserChatHistoryNotDeliveredAsync", chatNotDelivered); | 
		
	
		
			
				|  |  |  |  |       hubConnection.on("OnUpdateUserChatHistoryStatusAsync", updateUserChatStatus); | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |   } | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
	
		
			
				
					|  |  |  | @ -215,9 +235,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |   void updateChatHistoryWindow(List<Object?>? args) { | 
		
	
		
			
				|  |  |  |  |     dynamic items = args!.toList(); | 
		
	
		
			
				|  |  |  |  |     if (kDebugMode) { | 
		
	
		
			
				|  |  |  |  |     print("---------------------------------Update Chat History Windows  Async -------------------------------------"); | 
		
	
		
			
				|  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |     logger.d(items); | 
		
	
		
			
				|  |  |  |  |     // for (var user in searchedChats!) { | 
		
	
		
			
				|  |  |  |  |     //   if (user.id == items.first["id"]) { | 
		
	
	
		
			
				
					|  |  |  | 
 |