diff --git a/lib/provider/dashboard_provider_model.dart b/lib/provider/dashboard_provider_model.dart index eaa6277..c5286ef 100644 --- a/lib/provider/dashboard_provider_model.dart +++ b/lib/provider/dashboard_provider_model.dart @@ -134,15 +134,15 @@ class DashboardProviderModel with ChangeNotifier, DiagnosticableTreeMixin { workListCounter = genericResponseModel?.pOPENNTFNUMBER ?? 0; - if (showLoading) Utils.hideLoading(context); + itgFormsModel = await DashboardApiClient().getItgFormsPendingTask(); + workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0); GenericResponseModel? cocGenericResponseModel = await DashboardApiClient().getCOCNotifications(); cocCount = cocGenericResponseModel?.mohemmITGPendingTaskResponseItem; if (cocCount != null) { cocFinalCount = (cocCount?.escalation ?? 0) + (cocCount?.waitingToClose ?? 0) + (cocCount?.waitingForAcceptance ?? 0) + (cocCount?.extendTATRequest ?? 0); workListCounter += cocFinalCount; } - itgFormsModel = await DashboardApiClient().getItgFormsPendingTask(); - workListCounter = workListCounter + (itgFormsModel?.totalCount ?? 0); + if (showLoading) Utils.hideLoading(context); notifyListeners(); } catch (ex) { isWorkListLoading = false; diff --git a/lib/ui/work_list/work_list_screen.dart b/lib/ui/work_list/work_list_screen.dart index 190ac71..369bf0c 100644 --- a/lib/ui/work_list/work_list_screen.dart +++ b/lib/ui/work_list/work_list_screen.dart @@ -120,8 +120,9 @@ class _WorkListScreenState extends State { ItgFormsModel? itgFormsModel; int? itgRequestTypeIndex; - Future getWorkList({bool showLoading = true, bool callWorkList = true}) async { + Future getWorkList({bool showLoading = true}) async { try { + if (showLoading) Utils.showLoading(context); if (workListItemTypes[workListItemIndex].key == "ITG") { itgFormsModel = await WorkListApiClient().getITGTaskCountRequestType(); List requestAllList = []; @@ -137,36 +138,31 @@ class _WorkListScreenState extends State { itgRequestTypeIndex = 0; } } else { - if (showLoading) Utils.showLoading(context); itgRequestTypeIndex = null; - if (callWorkList) { - workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString()); - AppState().setWorkList = workList; - } - if (showLoading) Utils.hideLoading(context); - setState(() {}); + workList = await WorkListApiClient().getWorkList(pageNumber, workListItemTypes[workListItemIndex].key, pNotificationType.toString()); + AppState().setWorkList = workList; } + if (showLoading) Utils.hideLoading(context); + if (showLoading) setState(() {}); } catch (ex) { if (showLoading) Utils.hideLoading(context); if (showLoading) Utils.handleException(ex, context, null); } } - void _onRefresh({bool callWorkList = true}) async { + void _onRefresh() async { try { _refreshController.refreshCompleted(); - if(callWorkList) Utils.showLoading(context); + Utils.showLoading(context); List dataOnRefresh = await Future.wait([ - providerData.fetchWorkListCounter(context, showLoading: true).then((value) { - setState(() {}); - }), - getWorkList(showLoading: false, callWorkList: callWorkList), + providerData.fetchWorkListCounter(context, showLoading: false), + getWorkList(showLoading: false), ]); calculateCounter(); - if(callWorkList) Utils.hideLoading(context); + Utils.hideLoading(context); setState(() {}); } catch (ex) { - if(callWorkList) Utils.hideLoading(context); + Utils.hideLoading(context); Utils.handleException(ex, context, null); } } @@ -447,7 +443,6 @@ class _WorkListScreenState extends State { if (mounted) setState(() {}); } } else { - _onRefresh(callWorkList: false); if (mounted) setState(() {}); } }, diff --git a/lib/ui/work_list/worklist_detail_screen.dart b/lib/ui/work_list/worklist_detail_screen.dart index feb424e..f2cd760 100644 --- a/lib/ui/work_list/worklist_detail_screen.dart +++ b/lib/ui/work_list/worklist_detail_screen.dart @@ -40,7 +40,6 @@ import 'package:mohem_flutter_app/widgets/dialogs/accept_reject_input_dialog.dar import 'package:mohem_flutter_app/widgets/dialogs/confirm_dialog.dart'; class WorkListDetailScreen extends StatefulWidget { - WorkListDetailScreen({Key? key}) : super(key: key); @override @@ -100,8 +99,8 @@ class _WorkListDetailScreenState extends State { getUserInformation(); } - getNotificationButtons(); notificationGetRespondAttributes(); + getNotificationButtons(); getAttachments(); getActionHistory(); @@ -503,7 +502,7 @@ class _WorkListDetailScreenState extends State { } ], }; - if (actionMode == "APPROVED" || actionMode == "APPROVE" || actionMode == "CLOSE") { + if (actionMode == "APPROVED" || actionMode == "APPROVE") { performNotificationAction(payload); } else if (note.isNotEmpty && (actionMode != "APPROVED" || actionMode != "APPROVE")) { performNotificationAction(payload); @@ -540,34 +539,34 @@ class _WorkListDetailScreenState extends State { void getEitNotificationBody() async { try { - // if (apiCallCount == 0) Utils.showLoading(context); - // apiCallCount++; + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; getEitCollectionNotificationBodyList = await WorkListApiClient().GetEitNotificationBody(workListData!.nOTIFICATIONID); - // apiCallCount--; - // if (apiCallCount == 0) { - // Utils.hideLoading(context); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); setState(() {}); - // } + } } catch (ex) { - // apiCallCount--; - // Utils.hideLoading(context); + apiCallCount--; + Utils.hideLoading(context); Utils.handleException(ex, context, null); } } void getUserInformation() async { try { - // if (apiCallCount == 0) Utils.showLoading(context); - // apiCallCount++; + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; memberInformationListModel = await WorkListApiClient().getUserInformation(-999, workListData!.sELECTEDEMPLOYEENUMBER!); - // apiCallCount--; - // if (apiCallCount == 0) { - // Utils.hideLoading(context); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); setState(() {}); - // } + } } catch (ex) { - // apiCallCount--; - // Utils.hideLoading(context); + apiCallCount--; + Utils.hideLoading(context); Utils.handleException(ex, context, null); } } @@ -608,17 +607,17 @@ class _WorkListDetailScreenState extends State { void getAbsenceNotificationBody() async { try { - // if (apiCallCount == 0) Utils.showLoading(context); - // apiCallCount++; + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; getAbsenceCollectionNotificationBodyList = await WorkListApiClient().getAbsenceNotificationBody(workListData!.nOTIFICATIONID); - // apiCallCount--; - // if (apiCallCount == 0) { - // Utils.hideLoading(context); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); setState(() {}); - // } + } } catch (ex) { - // apiCallCount--; - // Utils.hideLoading(context); + apiCallCount--; + Utils.hideLoading(context); Utils.handleException(ex, context, null); } } @@ -731,20 +730,20 @@ class _WorkListDetailScreenState extends State { void notificationGetRespondAttributes() async { try { - // if (apiCallCount == 0) Utils.showLoading(context); - // apiCallCount++; + if (apiCallCount == 0) Utils.showLoading(context); + apiCallCount++; getNotificationRespondAttributes = await WorkListApiClient().notificationGetRespondAttributes(workListData!.nOTIFICATIONID!); if (getNotificationRespondAttributes.isNotEmpty) { notificationNoteInput = getNotificationRespondAttributes.first; } - // apiCallCount--; - // if (apiCallCount == 0) { - // Utils.hideLoading(context); + apiCallCount--; + if (apiCallCount == 0) { + Utils.hideLoading(context); setState(() {}); - // } + } } catch (ex) { - // apiCallCount--; - // Utils.hideLoading(context); + apiCallCount--; + Utils.hideLoading(context); Utils.handleException(ex, context, null); } }