From 9a6d2d44e16dc37798d418f00e155466897fb48c Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Tue, 12 Dec 2023 11:12:40 +0300 Subject: [PATCH 1/2] before staring participant fix. --- lib/classes/consts.dart | 2 +- lib/ui/chat/chat_detailed_screen.dart | 4 ++-- lib/ui/chat/group_chat_detaied_screen.dart | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 0dc4617..6ce549f 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,7 +3,7 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { //static String baseUrl = "http://10.200.204.20:2801/"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server diff --git a/lib/ui/chat/chat_detailed_screen.dart b/lib/ui/chat/chat_detailed_screen.dart index 01b2f47..93763d0 100644 --- a/lib/ui/chat/chat_detailed_screen.dart +++ b/lib/ui/chat/chat_detailed_screen.dart @@ -78,7 +78,7 @@ class _ChatDetailScreenState extends State { Widget build(BuildContext context) { params = ModalRoute.of(context)!.settings.arguments as ChatDetailedScreenParams; data = Provider.of(context, listen: false); - // callPro = Provider.of(context, listen: false); + // callPro = Provider.of(context, listen: false); if (params != null) { data.getSingleUserChatHistory( senderUID: AppState().chatDetails!.response!.id!.toInt(), @@ -143,7 +143,7 @@ class _ChatDetailScreenState extends State { dateTime: m.dateFormte(m.userChatHistory[i].createdDate!), cItem: m.userChatHistory[i], ), - onRightSwipe: (val) { + onRightSwipe: () { m.chatReply( m.userChatHistory[i], ); diff --git a/lib/ui/chat/group_chat_detaied_screen.dart b/lib/ui/chat/group_chat_detaied_screen.dart index 84ae3bd..c43a2df 100644 --- a/lib/ui/chat/group_chat_detaied_screen.dart +++ b/lib/ui/chat/group_chat_detaied_screen.dart @@ -147,7 +147,7 @@ class _GroupChatDetailScreenState extends State { dateTime: m.groupChatHistory[i].createdDate!, cItem: m.groupChatHistory[i], ), - onRightSwipe: (val) { + onRightSwipe: () { m.groupChatReply( m.groupChatHistory[i], ); From 684a200285df464e9935d4249c1cdeaf9b31353e Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Tue, 12 Dec 2023 17:28:26 +0300 Subject: [PATCH 2/2] Join MarathonProviderFix --- lib/api/marathon/marathon_api_client.dart | 5 ++--- lib/ui/marathon/marathon_provider.dart | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/api/marathon/marathon_api_client.dart b/lib/api/marathon/marathon_api_client.dart index 3d75d87..428e586 100644 --- a/lib/api/marathon/marathon_api_client.dart +++ b/lib/api/marathon/marathon_api_client.dart @@ -62,7 +62,6 @@ class MarathonApiClient { Future getMarathonDetails() async { String payrollString = AppState().postParamsObject?.payrollCodeStr.toString() ?? "CS"; - Response response = await ApiClient().getJsonForResponse( ApiConsts.marathonUpcomingUrl + payrollString, token: AppState().getMarathonToken == null || AppState().getMarathonToken == "" ? await getMarathonToken() : AppState().getMarathonToken, @@ -84,7 +83,7 @@ class MarathonApiClient { return marathonDetailModel; } - Future joinMarathonAsParticipant() async { + Future joinMarathonAsParticipant() async { Map jsonObject = { "employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER ?? "", "employeeNameAr": AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEAr ?? AppState().memberInformationList!.eMPLOYEEDISPLAYNAMEEn ?? "", @@ -95,7 +94,7 @@ class MarathonApiClient { return await ApiClient().postJsonForObject( (json) { MarathonGenericModel marathonModel = MarathonGenericModel.fromJson(json); - return marathonModel.data["remainingTime"]; + return marathonModel; }, ApiConsts.marathonJoinParticipantUrl, jsonObject, diff --git a/lib/ui/marathon/marathon_provider.dart b/lib/ui/marathon/marathon_provider.dart index b88f54b..0b1a783 100644 --- a/lib/ui/marathon/marathon_provider.dart +++ b/lib/ui/marathon/marathon_provider.dart @@ -10,6 +10,7 @@ import 'package:mohem_flutter_app/app_state/app_state.dart'; import 'package:mohem_flutter_app/classes/consts.dart'; import 'package:mohem_flutter_app/classes/utils.dart'; import 'package:mohem_flutter_app/config/routes.dart'; +import 'package:mohem_flutter_app/models/marathon/marathon_generic_model.dart'; import 'package:mohem_flutter_app/models/marathon/marathon_model.dart'; import 'package:mohem_flutter_app/models/marathon/question_model.dart'; import 'package:mohem_flutter_app/models/marathon/winner_model.dart'; @@ -193,9 +194,7 @@ class MarathonProvider extends ChangeNotifier { if (totalSecondsToWaitForMarathon == 0) { timer.cancel(); if (isUserWaiting) { - MarathonApiClient().joinMarathonAsParticipant().whenComplete(() async { - await callNextQuestionApi(); - }); + await callNextQuestionApi(); } else { isButtonEnabled = false; } @@ -575,9 +574,18 @@ class MarathonProvider extends ChangeNotifier { Future onJoinMarathonPressed(BuildContext context) async { try { - isUserWaiting = true; - Navigator.pushReplacementNamed(context, AppRoutes.marathonWaitingScreen); + Utils.showLoading(AppRoutes.navigatorKey.currentContext!); + MarathonApiClient().joinMarathonAsParticipant().then((MarathonGenericModel? marathonGenericModel) async { + Utils.hideLoading(AppRoutes.navigatorKey.currentContext!); + if (marathonGenericModel != null && marathonGenericModel.data != null) { + isUserWaiting = true; + Navigator.pushReplacementNamed(context, AppRoutes.marathonWaitingScreen); + } else if (marathonGenericModel!.data == null) { + Utils.showToast(marathonGenericModel.message.toString()); + } + }); } catch (e) { + Utils.hideLoading(AppRoutes.navigatorKey.currentContext!); Utils.confirmDialog(context, e.toString()); } }