From 9946c5b41e40fc66a559fd554a758fc32e576c07 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 7 Sep 2023 16:33:56 +0300 Subject: [PATCH] Code cleanup --- lib/redux/dashboard/dashboard_middleware.dart | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/redux/dashboard/dashboard_middleware.dart b/lib/redux/dashboard/dashboard_middleware.dart index df271aaca..c9d97c52b 100644 --- a/lib/redux/dashboard/dashboard_middleware.dart +++ b/lib/redux/dashboard/dashboard_middleware.dart @@ -25,25 +25,24 @@ Middleware _createViewDashboard() { return (Store store, dynamic dynamicAction, NextDispatcher next) { final action = dynamicAction as ViewDashboard; - if (!store.state.userCompany.canViewDashboard) { - store.dispatch(ViewClientList()); - next(action); - return; - } - checkForChanges( store: store, force: action.force, callback: () { - if (store.state.isStale) { - store.dispatch(RefreshData()); - } + if (!store.state.userCompany.canViewDashboard) { + store.dispatch(ViewClientList()); + } else { + if (store.state.isStale) { + store.dispatch(RefreshData()); + } - store.dispatch(UpdateCurrentRoute(DashboardScreenBuilder.route)); + store.dispatch(UpdateCurrentRoute(DashboardScreenBuilder.route)); + } next(action); - if (store.state.prefState.isMobile) { + if (store.state.prefState.isMobile && + store.state.userCompany.canViewDashboard) { navigatorKey.currentState.pushNamedAndRemoveUntil( DashboardScreenBuilder.route, (Route route) => false); }