Fix loading data
This commit is contained in:
parent
afde837684
commit
280e0f7e9e
|
|
@ -301,31 +301,41 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
InvoiceEmailScreen.route: (context) => InvoiceEmailScreen(),
|
||||
// STARTER: routes - do not remove comment
|
||||
DocumentScreen.route: (context) {
|
||||
if (widget.store.state.documentState.isStale) {
|
||||
widget.store.dispatch(LoadDocuments());
|
||||
}
|
||||
return DocumentScreen();
|
||||
},
|
||||
DocumentViewScreen.route: (context) => DocumentViewScreen(),
|
||||
DocumentEditScreen.route: (context) => DocumentEditScreen(),
|
||||
ExpenseScreen.route: (context) {
|
||||
if (widget.store.state.expenseState.isStale) {
|
||||
widget.store.dispatch(LoadExpenses());
|
||||
}
|
||||
return ExpenseScreen();
|
||||
},
|
||||
ExpenseViewScreen.route: (context) => ExpenseViewScreen(),
|
||||
ExpenseEditScreen.route: (context) => ExpenseEditScreen(),
|
||||
VendorScreen.route: (context) {
|
||||
if (widget.store.state.vendorState.isStale) {
|
||||
widget.store.dispatch(LoadVendors());
|
||||
}
|
||||
return VendorScreen();
|
||||
},
|
||||
VendorViewScreen.route: (context) => VendorViewScreen(),
|
||||
VendorEditScreen.route: (context) => VendorEditScreen(),
|
||||
TaskScreen.route: (context) {
|
||||
if (widget.store.state.taskState.isStale) {
|
||||
widget.store.dispatch(LoadTasks());
|
||||
}
|
||||
return TaskScreen();
|
||||
},
|
||||
TaskViewScreen.route: (context) => TaskViewScreen(),
|
||||
TaskEditScreen.route: (context) => TaskEditScreen(),
|
||||
ProjectScreen.route: (context) {
|
||||
if (widget.store.state.projectState.isStale) {
|
||||
widget.store.dispatch(LoadProjects());
|
||||
}
|
||||
return ProjectScreen();
|
||||
},
|
||||
ProjectViewScreen.route: (context) => ProjectViewScreen(),
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ Middleware<AppState> _viewClientList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
ClientScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.clientState.isStale) {
|
||||
store.dispatch(LoadClients());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ Middleware<AppState> _viewExpenseList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
ExpenseScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.expenseState.isStale) {
|
||||
store.dispatch(LoadExpenses());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ Middleware<AppState> _viewInvoiceList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
InvoiceScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.invoiceState.isStale) {
|
||||
store.dispatch(LoadInvoices());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ Middleware<AppState> _viewPaymentList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
PaymentScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.paymentState.isStale) {
|
||||
store.dispatch(LoadPayments());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ Middleware<AppState> _viewProductList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
ProductScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.productState.isStale) {
|
||||
store.dispatch(LoadProducts());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ Middleware<AppState> _viewProjectList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
ProjectScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.projectState.isStale) {
|
||||
store.dispatch(LoadProjects());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ Middleware<AppState> _viewQuoteList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
QuoteScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.quoteState.isStale) {
|
||||
store.dispatch(LoadQuotes());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ Middleware<AppState> _viewTaskList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
TaskScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.taskState.isStale) {
|
||||
store.dispatch(LoadTasks());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ Middleware<AppState> _viewVendorList() {
|
|||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
VendorScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.vendorState.isStale) {
|
||||
store.dispatch(LoadVendors());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,11 +72,23 @@ Middleware<AppState> _viewStub() {
|
|||
|
||||
Middleware<AppState> _viewStubList() {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as ViewStubList;
|
||||
|
||||
if (hasChanges(
|
||||
store: store, context: action.context, force: action.force)) {
|
||||
return;
|
||||
}
|
||||
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(StubScreen.route));
|
||||
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(StubScreen.route, (Route<dynamic> route) => false);
|
||||
if (isMobile(action.context)) {
|
||||
Navigator.of(action.context).pushNamedAndRemoveUntil(
|
||||
StubScreen.route, (Route<dynamic> route) => false);
|
||||
} else if (store.state.stubState.isStale) {
|
||||
store.dispatch(LoadStubs());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue