diff --git a/lib/api/chat/chat_provider_model.dart b/lib/api/chat/chat_provider_model.dart index 0f0e94c..a61a57a 100644 --- a/lib/api/chat/chat_provider_model.dart +++ b/lib/api/chat/chat_provider_model.dart @@ -93,20 +93,12 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { void getSingleUserChatHistory({required String senderUID, required int receiverUID, required bool loadMore}) async { isLoading = true; - print(loadMore); - print(senderUID); - print(receiverUID); if (!loadMore) paginationVal = 0; - print(paginationVal); isChatScreenActive = true; Response response = await ApiClient().getJsonForResponse( "${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal", token: AppState().chatDetails!.response!.token, ); - logger.d("${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal"); - logger.d("${AppState().chatDetails!.response!.token}"); - logger.d(jsonEncode(response.body)); - logger.d(jsonEncode(response.statusCode)); if (response.statusCode == 204) { if (!loadMore) userChatHistory = []; Utils.showToast("No More Data To Load"); @@ -119,10 +111,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } isLoading = false; - //Timer(const Duration(milliseconds: 100),() => scrollToBottom()); notifyListeners(); - - // scrollToBottom(); } List getSingleUserChatModel(String str) => List.from(json.decode(str).map((x) => SingleUserChatModel.fromJson(x))); @@ -364,15 +353,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } } - // void scrollDown() { - // scrollController.animateTo( - // scrollController.position.maxScrollExtent + 100, - // curve: Curves.easeOut, - // duration: const Duration(milliseconds: 300), - // ); - // notifyListeners(); - // } - 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(); @@ -605,22 +585,10 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin { } void scrollToBottom() { - //scrollController.jumpTo(scrollController.position.maxScrollExtent + 100 ); scrollController.animateTo( scrollController.position.maxScrollExtent + 100, duration: const Duration(milliseconds: 500), curve: Curves.easeIn, ); } - -// void scrollToMaxExtent() { -// WidgetsBinding.instance.addPostFrameCallback((_) { -// scrollController.animateTo( -// scrollController.position.maxScrollExtent, -// duration: const Duration(milliseconds: 100), -// curve: Curves.easeIn, -// ); -// }); -// } - } diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index ede22e3..93b4ea8 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -1,7 +1,7 @@ class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server - //static String baseUrl = "https://hmgwebservices.com"; // Live server + // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/ui/chat/chat_home.dart b/lib/ui/chat/chat_home.dart index d3c4d62..ea53d2e 100644 --- a/lib/ui/chat/chat_home.dart +++ b/lib/ui/chat/chat_home.dart @@ -30,7 +30,9 @@ class _ChatHomeState extends State { @override Widget build(BuildContext context) { data = Provider.of(context, listen: false); - data.getUserAutoLoginToken().whenComplete(() => null); + data.getUserAutoLoginToken().then((value){ + data.getUserRecentChats(); + }); return Scaffold( backgroundColor: MyColors.white, appBar: AppBarWidget( diff --git a/lib/ui/chat/chat_home_screen.dart b/lib/ui/chat/chat_home_screen.dart index e55f018..1b351e5 100644 --- a/lib/ui/chat/chat_home_screen.dart +++ b/lib/ui/chat/chat_home_screen.dart @@ -23,19 +23,15 @@ class ChatHomeScreen extends StatefulWidget { class _ChatHomeScreenState extends State { TextEditingController search = TextEditingController(); - late ChatProviderModel data; @override void initState() { super.initState(); - data = Provider.of(context, listen: false); - data.getUserRecentChats(); } @override void dispose() { super.dispose(); - data.hubConnection.stop(); } @override