Code cleanup

This commit is contained in:
Hillel Coren 2023-09-07 16:33:56 +03:00
parent 593c85913c
commit 9946c5b41e
1 changed files with 10 additions and 11 deletions

View File

@ -25,25 +25,24 @@ Middleware<AppState> _createViewDashboard() {
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewDashboard; final action = dynamicAction as ViewDashboard;
if (!store.state.userCompany.canViewDashboard) {
store.dispatch(ViewClientList());
next(action);
return;
}
checkForChanges( checkForChanges(
store: store, store: store,
force: action.force, force: action.force,
callback: () { callback: () {
if (!store.state.userCompany.canViewDashboard) {
store.dispatch(ViewClientList());
} else {
if (store.state.isStale) { if (store.state.isStale) {
store.dispatch(RefreshData()); store.dispatch(RefreshData());
} }
store.dispatch(UpdateCurrentRoute(DashboardScreenBuilder.route)); store.dispatch(UpdateCurrentRoute(DashboardScreenBuilder.route));
}
next(action); next(action);
if (store.state.prefState.isMobile) { if (store.state.prefState.isMobile &&
store.state.userCompany.canViewDashboard) {
navigatorKey.currentState.pushNamedAndRemoveUntil( navigatorKey.currentState.pushNamedAndRemoveUntil(
DashboardScreenBuilder.route, (Route<dynamic> route) => false); DashboardScreenBuilder.route, (Route<dynamic> route) => false);
} }