Refactor
This commit is contained in:
parent
e826160b03
commit
a0570c421c
|
|
@ -140,15 +140,17 @@ Middleware<AppState> _createLoadState(
|
|||
..companyState5.replace(company5State));
|
||||
store.dispatch(LoadStateSuccess(appState));
|
||||
|
||||
if (uiState.currentRoute != LoginVM.route && authState.url.isNotEmpty) {
|
||||
NavigatorState navigator = Navigator
|
||||
.of(action.context);
|
||||
if (uiState.currentRoute != LoginVM.route &&
|
||||
authState.url.isNotEmpty) {
|
||||
NavigatorState navigator = Navigator.of(action.context);
|
||||
var route = '';
|
||||
bool isFirst = true;
|
||||
uiState.currentRoute.split('/').forEach((part) {
|
||||
if (part.isNotEmpty) {
|
||||
if (part == 'edit' && route != '/products' && route != '/invoices') {
|
||||
navigator.pushNamed(route + '/view');
|
||||
if (part == 'edit' &&
|
||||
route != '/products' &&
|
||||
route != '/invoices') {
|
||||
navigator.pushNamed(route + '/view');
|
||||
}
|
||||
route += '/' + part;
|
||||
if (isFirst) {
|
||||
|
|
@ -177,6 +179,28 @@ Middleware<AppState> _createLoadState(
|
|||
};
|
||||
}
|
||||
|
||||
List<String> _getPages(AppState state, String currentRoute) {
|
||||
List<String> routes = [];
|
||||
var route = '';
|
||||
|
||||
currentRoute.split('/').forEach((part) {
|
||||
if (part.isNotEmpty) {
|
||||
if (part == 'edit' && route != '/products' && route != '/invoices') {
|
||||
switch (route) {
|
||||
case '/clients':
|
||||
if (!state.clientUIState.selected.isNew()) {
|
||||
routes.add(route + '/view');
|
||||
}
|
||||
}
|
||||
}
|
||||
route += '/' + part;
|
||||
routes.add(route);
|
||||
}
|
||||
});
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
_handleError(store, error) {
|
||||
print(error);
|
||||
store.dispatch(UserLogout());
|
||||
|
|
@ -209,7 +233,6 @@ Middleware<AppState> _createUserLoggedIn(
|
|||
|
||||
Middleware<AppState> _createUIChange(PersistenceRepository uiRepository) {
|
||||
return (Store<AppState> store, action, NextDispatcher next) {
|
||||
|
||||
next(action);
|
||||
|
||||
uiRepository.saveUIState(store.state.uiState);
|
||||
|
|
@ -224,7 +247,6 @@ Middleware<AppState> _createDataLoaded(
|
|||
PersistenceRepository company5Repository,
|
||||
) {
|
||||
return (Store<AppState> store, action, NextDispatcher next) {
|
||||
|
||||
// first process the action so the data is in the state
|
||||
next(action);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import 'package:invoiceninja/data/models/models.dart';
|
|||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja/redux/client/client_actions.dart';
|
||||
import 'package:invoiceninja/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/snackbar_row.dart';
|
||||
import 'package:invoiceninja/ui/client/client_screen.dart';
|
||||
import 'package:invoiceninja/ui/client/edit/client_edit.dart';
|
||||
import 'package:invoiceninja/ui/client/view/client_view_vm.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
class ClientEditScreen extends StatelessWidget {
|
||||
|
|
@ -71,6 +73,7 @@ class ClientEditVM {
|
|||
store.dispatch(
|
||||
SaveClientRequest(completer: completer, client: client));
|
||||
return completer.future.then((_) {
|
||||
/*
|
||||
if (client.isNew()) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator
|
||||
|
|
@ -79,7 +82,7 @@ class ClientEditVM {
|
|||
} else {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
/*
|
||||
*/
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: client.isNew()
|
||||
|
|
@ -87,7 +90,7 @@ class ClientEditVM {
|
|||
: AppLocalization.of(context).successfullyUpdatedClient,
|
||||
),
|
||||
duration: Duration(seconds: 3)));
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue