@ -131,21 +131,46 @@ class DashboardVMProvider extends BaseVM with WidgetsBindingObserver {
final adVM = context . read < AdVM > ( ) ;
final subscriptionsVM = context . read < SubscriptionsVM > ( ) ;
/ / Set loading state immediately to prevent " No data " flash
adVM . setState ( ViewState . busy ) ;
appointmentVM . setState ( ViewState . busy ) ;
requestsVM . setState ( ViewState . busy ) ;
serviceVM . setState ( ViewState . busy ) ;
/ / ✅ Inject ViewModels into ChatVM ( only needs to be done once , but safe to repeat )
chatVM . setViewModels ( requestsVM: requestsVM , adVM: adVM ) ;
await requestsVM . populateDataForRequestsFilter ( ) ;
await requestsVM . populateDeliveryOptionEnums ( ) ;
await appointmentVM . populateAppointmentsFilterList ( ) ;
await adVM . populateAdsFilterList ( ) ;
await serviceVM . populateBranchServiceFilters ( ) ;
await serviceVM . getBranchAndServices ( ) ;
await requestsVM . getRequests ( ) ;
await subscriptionsVM . getSubscriptionBySP ( AppState ( ) . getUser . data ? . userInfo ? . providerId . toString ( ) ? ? " " , true ) ;
/ / Call independent filter population APIs in parallel
await Future . wait < dynamic > ( [
requestsVM . populateDataForRequestsFilter ( ) ,
requestsVM . populateDeliveryOptionEnums ( ) ,
appointmentVM . populateAppointmentsFilterList ( ) ,
adVM . populateAdsFilterList ( ) ,
serviceVM . populateBranchServiceFilters ( ) ,
shippingManagementVM . populateShippingRequestFilterList ( ) ,
shippingManagementVM . populateSelfPickupRequestFilterList ( ) ,
adVM . getVehicleTypes ( ) ,
adVM . getVehicleAdsDuration ( ) ,
] ) ;
/ / Call data APIs in parallel
await Future . wait < dynamic > ( [
serviceVM . getBranchAndServices ( ) ,
requestsVM . getRequests ( ) ,
subscriptionsVM . getSubscriptionBySP ( AppState ( ) . getUser . data ? . userInfo ? . providerId . toString ( ) ? ? " " , true ) ,
appointmentVM . applyFilterOnAppointmentsVMForProviders (
appointmentStatusEnum: AppointmentStatusEnum . allAppointments ,
isNeedCustomerFilter: true ,
shouldPopulateUpcoming: true ,
) ,
] ) ;
/ / Call ads APIs in parallel ( conditionally )
if ( dashboardRouteEnum ! = DashboardRouteEnum . fromAdsPayment & & dashboardRouteEnum ! = DashboardRouteEnum . fromAdsSubmit & & dashboardRouteEnum ! = DashboardRouteEnum . fromReserveAdsPayment ) {
await adVM . getMyAds ( ) ;
await adVM . getExploreAds ( ) ;
await Future . wait < dynamic > ( [
adVM . getMyAds ( ) ,
adVM . getExploreAds ( ) ,
] ) ;
}
/ / Handle reserve ads payment completion
@ -156,16 +181,7 @@ class DashboardVMProvider extends BaseVM with WidgetsBindingObserver {
log ( " ✅ Successfully navigated to Reserved Ads after payment " ) ;
}
await shippingManagementVM . populateShippingRequestFilterList ( ) ;
await shippingManagementVM . populateSelfPickupRequestFilterList ( ) ;
await appointmentVM . applyFilterOnAppointmentsVMForProviders (
appointmentStatusEnum: AppointmentStatusEnum . allAppointments ,
isNeedCustomerFilter: true ,
shouldPopulateUpcoming: true ,
) ;
await adVM . getVehicleTypes ( ) ;
await adVM . getVehicleAdsDuration ( ) ;
/ / Build chat hub connection last
await chatVM . buildHubConnection ( context: context ) ;
}