diff --git a/lib/ui/client/edit/client_edit_vm.dart b/lib/ui/client/edit/client_edit_vm.dart index 87a75130b..b1899eb19 100644 --- a/lib/ui/client/edit/client_edit_vm.dart +++ b/lib/ui/client/edit/client_edit_vm.dart @@ -62,7 +62,7 @@ class ClientEditVM { isSaving: state.isSaving, onBackPressed: () { if (state.uiState.currentRoute.contains(ClientScreen.route)) { - store.dispatch(UpdateCurrentRoute(ClientViewScreen.route)); + store.dispatch(UpdateCurrentRoute(ClientScreen.route)); } }, onChanged: (ClientEntity client) => @@ -81,6 +81,10 @@ class ClientEditVM { store.dispatch( SaveClientRequest(completer: completer, client: client)); return completer.future.then((savedClient) { + if (state.uiState.currentRoute.contains(ClientScreen.route)) { + store.dispatch(UpdateCurrentRoute( + client.isNew ? ClientScreen.route : ClientViewScreen.route)); + } if (client.isNew) { if ([ InvoiceEditScreen.route, diff --git a/lib/ui/invoice/edit/invoice_edit_vm.dart b/lib/ui/invoice/edit/invoice_edit_vm.dart index d14cdedb5..dcba3ea48 100644 --- a/lib/ui/invoice/edit/invoice_edit_vm.dart +++ b/lib/ui/invoice/edit/invoice_edit_vm.dart @@ -87,7 +87,8 @@ class InvoiceEditVM extends EntityEditVM { origInvoice: store.state.invoiceState.map[invoice.id], onBackPressed: () { if (state.uiState.currentRoute.contains(InvoiceScreen.route)) { - store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route)); + store.dispatch(UpdateCurrentRoute( + invoice.isNew ? InvoiceScreen.route : InvoiceViewScreen.route)); } }, onSavePressed: (BuildContext context) { @@ -95,6 +96,7 @@ class InvoiceEditVM extends EntityEditVM { store.dispatch( SaveInvoiceRequest(completer: completer, invoice: invoice)); return completer.future.then((savedInvoice) { + store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route)); if (invoice.isNew) { Navigator.of(context).pushReplacementNamed(InvoiceViewScreen.route); } else { diff --git a/lib/ui/payment/edit/payment_edit_vm.dart b/lib/ui/payment/edit/payment_edit_vm.dart index 975383c99..ecc3e2799 100644 --- a/lib/ui/payment/edit/payment_edit_vm.dart +++ b/lib/ui/payment/edit/payment_edit_vm.dart @@ -84,12 +84,14 @@ class PaymentEditVM { }, onBackPressed: () { if (state.uiState.currentRoute.contains(PaymentScreen.route)) { - store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route)); + store.dispatch(UpdateCurrentRoute( + payment.isNew ? PaymentScreen.route : PaymentViewScreen.route)); } }, onSavePressed: (BuildContext context) { final Completer completer = errorCompleter(context) ..future.then((_) { + store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route)); if (payment.isNew) { Navigator.of(context) .pushReplacementNamed(PaymentViewScreen.route); diff --git a/lib/ui/project/edit/project_edit_vm.dart b/lib/ui/project/edit/project_edit_vm.dart index 070b00feb..7188b1479 100644 --- a/lib/ui/project/edit/project_edit_vm.dart +++ b/lib/ui/project/edit/project_edit_vm.dart @@ -69,7 +69,8 @@ class ProjectEditVM { }, onBackPressed: () { if (state.uiState.currentRoute.contains(ProjectScreen.route)) { - store.dispatch(UpdateCurrentRoute(ProjectViewScreen.route)); + store.dispatch(UpdateCurrentRoute( + project.isNew ? ProjectScreen.route : ProjectViewScreen.route)); } }, onAddClientPressed: (context, completer) { @@ -91,6 +92,9 @@ class ProjectEditVM { store.dispatch( SaveProjectRequest(completer: completer, project: project)); return completer.future.then((savedProject) { + if (state.uiState.currentRoute.contains(ProjectScreen.route)) { + store.dispatch(UpdateCurrentRoute(ProjectScreen.route)); + } if (project.isNew) { if ([ TaskEditScreen.route, diff --git a/lib/ui/quote/edit/quote_edit_vm.dart b/lib/ui/quote/edit/quote_edit_vm.dart index bbad472df..a2b65102e 100644 --- a/lib/ui/quote/edit/quote_edit_vm.dart +++ b/lib/ui/quote/edit/quote_edit_vm.dart @@ -66,7 +66,8 @@ class QuoteEditVM extends EntityEditVM { origInvoice: store.state.quoteState.map[quote.id], onBackPressed: () { if (state.uiState.currentRoute.contains(QuoteScreen.route)) { - store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route)); + store.dispatch(UpdateCurrentRoute( + quote.isNew ? QuoteScreen.route : QuoteViewScreen.route)); } }, onSavePressed: (BuildContext context) { diff --git a/stubs/ui/stub/edit/stub_edit_vm b/stubs/ui/stub/edit/stub_edit_vm index b965db800..3227303cb 100644 --- a/stubs/ui/stub/edit/stub_edit_vm +++ b/stubs/ui/stub/edit/stub_edit_vm @@ -61,7 +61,7 @@ class StubEditVM { }, onBackPressed: () { if (state.uiState.currentRoute.contains(StubScreen.route)) { - store.dispatch(UpdateCurrentRoute(StubViewScreen.route)); + store.dispatch(UpdateCurrentRoute(stub.isNew ? StubScreen.route : StubViewScreen.route)); } }, onSavePressed: (BuildContext context) {