From b8dd5b8810547eb031558994f741e995bc4cd888 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 17 Nov 2019 21:31:57 +0200 Subject: [PATCH] Refactor --- lib/constants.dart | 4 ++-- lib/redux/client/client_middleware.dart | 8 ++------ .../company_gateway/company_gateway_middleware.dart | 9 ++------- lib/redux/document/document_middleware.dart | 8 ++------ lib/redux/expense/expense_middleware.dart | 8 ++------ lib/redux/group/group_middleware.dart | 8 ++------ lib/redux/invoice/invoice_middleware.dart | 8 ++------ lib/redux/payment/payment_middleware.dart | 8 ++------ lib/redux/product/product_middleware.dart | 8 ++------ lib/redux/project/project_middleware.dart | 8 ++------ lib/redux/quote/quote_middleware.dart | 8 ++------ lib/redux/task/task_middleware.dart | 8 ++------ lib/redux/tax_rate/tax_rate_middleware.dart | 8 ++------ lib/redux/user/user_middleware.dart | 8 ++------ lib/redux/vendor/vendor_middleware.dart | 8 ++------ stubs/redux/stub/stub_middleware | 9 ++------- 16 files changed, 32 insertions(+), 94 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index 05246d5a5..7a3e2cede 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; // This version must be updated in tandem with the pubspec version. const String kAppVersion = '2.0.2'; const String kSiteUrl = 'https://invoiceninja.com'; -const String kAppUrl = 'https://admin.invoiceninja.com'; -//const String kAppUrl = 'https://staging.invoicing.co'; +//const String kAppUrl = 'https://admin.invoiceninja.com'; +const String kAppUrl = 'https://staging.invoicing.co'; //const String kAppUrl = ''; const String kAppPlansURL = diff --git a/lib/redux/client/client_middleware.dart b/lib/redux/client/client_middleware.dart index 0b34fc9de..c23a23174 100644 --- a/lib/redux/client/client_middleware.dart +++ b/lib/redux/client/client_middleware.dart @@ -41,7 +41,7 @@ List> createStoreClientsMiddleware([ Middleware _editClient() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditClient; if (!action.force && @@ -54,11 +54,7 @@ Middleware _editClient() { store.dispatch(UpdateCurrentRoute(ClientEditScreen.route)); if (isMobile(action.context)) { - final client = await action.navigator.pushNamed(ClientEditScreen.route); - - if (action.completer != null && client != null) { - action.completer.complete(client); - } + action.navigator.pushNamed(ClientEditScreen.route); } }; } diff --git a/lib/redux/company_gateway/company_gateway_middleware.dart b/lib/redux/company_gateway/company_gateway_middleware.dart index de95e57ac..77ab1e9bc 100644 --- a/lib/redux/company_gateway/company_gateway_middleware.dart +++ b/lib/redux/company_gateway/company_gateway_middleware.dart @@ -44,7 +44,7 @@ List> createStoreCompanyGatewaysMiddleware([ Middleware _editCompanyGateway() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditCompanyGateway; if (!action.force && @@ -57,12 +57,7 @@ Middleware _editCompanyGateway() { store.dispatch(UpdateCurrentRoute(CompanyGatewayEditScreen.route)); if (isMobile(action.context)) { - final companyGateway = - await action.navigator.pushNamed(CompanyGatewayEditScreen.route); - - if (action.completer != null && companyGateway != null) { - action.completer.complete(companyGateway); - } + action.navigator.pushNamed(CompanyGatewayEditScreen.route); } }; } diff --git a/lib/redux/document/document_middleware.dart b/lib/redux/document/document_middleware.dart index c0cf5d5dc..b65ccf96b 100644 --- a/lib/redux/document/document_middleware.dart +++ b/lib/redux/document/document_middleware.dart @@ -40,7 +40,7 @@ List> createStoreDocumentsMiddleware([ Middleware _editDocument() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditDocument; next(action); @@ -48,11 +48,7 @@ Middleware _editDocument() { store.dispatch(UpdateCurrentRoute(DocumentEditScreen.route)); if (isMobile(action.context)) { - final document = await action.navigator.pushNamed(DocumentEditScreen.route); - - if (action.completer != null && document != null) { - action.completer.complete(document); - } + action.navigator.pushNamed(DocumentEditScreen.route); } }; } diff --git a/lib/redux/expense/expense_middleware.dart b/lib/redux/expense/expense_middleware.dart index 6376e4db0..5e146ad07 100644 --- a/lib/redux/expense/expense_middleware.dart +++ b/lib/redux/expense/expense_middleware.dart @@ -42,7 +42,7 @@ List> createStoreExpensesMiddleware([ Middleware _editExpense() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditExpense; if (!action.force && @@ -55,11 +55,7 @@ Middleware _editExpense() { store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); if (isMobile(action.context)) { - final expense = await action.navigator.pushNamed(ExpenseEditScreen.route); - - if (action.completer != null && expense != null) { - action.completer.complete(expense); - } + action.navigator.pushNamed(ExpenseEditScreen.route); } }; } diff --git a/lib/redux/group/group_middleware.dart b/lib/redux/group/group_middleware.dart index 6366cc0dc..e1c04a651 100644 --- a/lib/redux/group/group_middleware.dart +++ b/lib/redux/group/group_middleware.dart @@ -41,7 +41,7 @@ List> createStoreGroupsMiddleware([ Middleware _editGroup() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditGroup; if (!action.force && @@ -54,11 +54,7 @@ Middleware _editGroup() { store.dispatch(UpdateCurrentRoute(GroupEditScreen.route)); if (isMobile(action.context)) { - final group = await action.navigator.pushNamed(GroupEditScreen.route); - - if (action.completer != null && group != null) { - action.completer.complete(group); - } + action.navigator.pushNamed(GroupEditScreen.route); } }; } diff --git a/lib/redux/invoice/invoice_middleware.dart b/lib/redux/invoice/invoice_middleware.dart index 60bd43624..0aa7b214c 100644 --- a/lib/redux/invoice/invoice_middleware.dart +++ b/lib/redux/invoice/invoice_middleware.dart @@ -95,7 +95,7 @@ Middleware _viewInvoice() { Middleware _editInvoice() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditInvoice; if (!action.force && @@ -108,11 +108,7 @@ Middleware _editInvoice() { store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route)); if (isMobile(action.context)) { - final invoice = await action.navigator.pushNamed(InvoiceEditScreen.route); - - if (action.completer != null && invoice != null) { - action.completer.complete(invoice); - } + action.navigator.pushNamed(InvoiceEditScreen.route); } }; } diff --git a/lib/redux/payment/payment_middleware.dart b/lib/redux/payment/payment_middleware.dart index 06a5fe6b7..5d7c357e3 100644 --- a/lib/redux/payment/payment_middleware.dart +++ b/lib/redux/payment/payment_middleware.dart @@ -44,7 +44,7 @@ List> createStorePaymentsMiddleware([ Middleware _editPayment() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditPayment; if (!action.force && @@ -57,11 +57,7 @@ Middleware _editPayment() { store.dispatch(UpdateCurrentRoute(PaymentEditScreen.route)); if (isMobile(action.context)) { - final payment = await action.navigator.pushNamed(PaymentEditScreen.route); - - if (action.completer != null && payment != null) { - action.completer.complete(null); - } + action.navigator.pushNamed(PaymentEditScreen.route); } }; } diff --git a/lib/redux/product/product_middleware.dart b/lib/redux/product/product_middleware.dart index c9e7b3633..0fd069ed3 100644 --- a/lib/redux/product/product_middleware.dart +++ b/lib/redux/product/product_middleware.dart @@ -38,7 +38,7 @@ List> createStoreProductsMiddleware([ Middleware _editProduct() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditProduct; if (!action.force && @@ -51,11 +51,7 @@ Middleware _editProduct() { store.dispatch(UpdateCurrentRoute(ProductEditScreen.route)); if (isMobile(action.context)) { - final product = await action.navigator.pushNamed(ProductEditScreen.route); - - if (action.completer != null && product != null) { - action.completer.complete(product); - } + action.navigator.pushNamed(ProductEditScreen.route); } }; } diff --git a/lib/redux/project/project_middleware.dart b/lib/redux/project/project_middleware.dart index a1e893ef8..28ce9b043 100644 --- a/lib/redux/project/project_middleware.dart +++ b/lib/redux/project/project_middleware.dart @@ -42,7 +42,7 @@ List> createStoreProjectsMiddleware([ Middleware _editProject() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditProject; if (!action.force && @@ -55,11 +55,7 @@ Middleware _editProject() { store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route)); if (isMobile(action.context)) { - final project = await action.navigator.pushNamed(ProjectEditScreen.route); - - if (action.completer != null && project != null) { - action.completer.complete(project); - } + action.navigator.pushNamed(ProjectEditScreen.route); } }; } diff --git a/lib/redux/quote/quote_middleware.dart b/lib/redux/quote/quote_middleware.dart index a1d508523..2e1213b79 100644 --- a/lib/redux/quote/quote_middleware.dart +++ b/lib/redux/quote/quote_middleware.dart @@ -95,7 +95,7 @@ Middleware _viewQuoteList() { Middleware _editQuote() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditQuote; if (!action.force && @@ -108,11 +108,7 @@ Middleware _editQuote() { store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route)); if (isMobile(action.context)) { - final quote = await action.navigator.pushNamed(QuoteEditScreen.route); - - if (action.completer != null && quote != null) { - action.completer.complete(quote); - } + action.navigator.pushNamed(QuoteEditScreen.route); } }; } diff --git a/lib/redux/task/task_middleware.dart b/lib/redux/task/task_middleware.dart index 59826aa95..4f6e20b8e 100644 --- a/lib/redux/task/task_middleware.dart +++ b/lib/redux/task/task_middleware.dart @@ -41,7 +41,7 @@ List> createStoreTasksMiddleware([ Middleware _editTask() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditTask; if (!action.force && @@ -54,11 +54,7 @@ Middleware _editTask() { store.dispatch(UpdateCurrentRoute(TaskEditScreen.route)); if (isMobile(action.context)) { - final task = await action.navigator.pushNamed(TaskEditScreen.route); - - if (action.completer != null && task != null) { - action.completer.complete(task); - } + action.navigator.pushNamed(TaskEditScreen.route); } }; } diff --git a/lib/redux/tax_rate/tax_rate_middleware.dart b/lib/redux/tax_rate/tax_rate_middleware.dart index c4c74e3f2..4ff424d96 100644 --- a/lib/redux/tax_rate/tax_rate_middleware.dart +++ b/lib/redux/tax_rate/tax_rate_middleware.dart @@ -40,7 +40,7 @@ List> createStoreTaxRatesMiddleware([ Middleware _editTaxRate() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditTaxRate; if (!action.force && @@ -53,11 +53,7 @@ Middleware _editTaxRate() { store.dispatch(UpdateCurrentRoute(TaxRateEditScreen.route)); if (isMobile(action.context)) { - final taxRate = await action.navigator.pushNamed(TaxRateEditScreen.route); - - if (action.completer != null && taxRate != null) { - action.completer.complete(taxRate); - } + action.navigator.pushNamed(TaxRateEditScreen.route); } }; } diff --git a/lib/redux/user/user_middleware.dart b/lib/redux/user/user_middleware.dart index 836b7897c..a7e473782 100644 --- a/lib/redux/user/user_middleware.dart +++ b/lib/redux/user/user_middleware.dart @@ -40,7 +40,7 @@ List> createStoreUsersMiddleware([ Middleware _editUser() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditUser; if (!action.force && @@ -53,11 +53,7 @@ Middleware _editUser() { store.dispatch(UpdateCurrentRoute(UserEditScreen.route)); if (isMobile(action.context)) { - final user = await action.navigator.pushNamed(UserEditScreen.route); - - if (action.completer != null && user != null) { - action.completer.complete(user); - } + action.navigator.pushNamed(UserEditScreen.route); } }; } diff --git a/lib/redux/vendor/vendor_middleware.dart b/lib/redux/vendor/vendor_middleware.dart index 70f297a98..a92f5b670 100644 --- a/lib/redux/vendor/vendor_middleware.dart +++ b/lib/redux/vendor/vendor_middleware.dart @@ -42,7 +42,7 @@ List> createStoreVendorsMiddleware([ Middleware _editVendor() { return (Store store, dynamic dynamicAction, - NextDispatcher next) async { + NextDispatcher next) { final action = dynamicAction as EditVendor; if (!action.force && @@ -55,11 +55,7 @@ Middleware _editVendor() { store.dispatch(UpdateCurrentRoute(VendorEditScreen.route)); if (isMobile(action.context)) { - final vendor = await action.navigator.pushNamed(VendorEditScreen.route); - - if (action.completer != null && vendor != null) { - action.completer.complete(vendor); - } + action.navigator.pushNamed(VendorEditScreen.route); } }; } diff --git a/stubs/redux/stub/stub_middleware b/stubs/redux/stub/stub_middleware index 7d1303566..b81f2752e 100644 --- a/stubs/redux/stub/stub_middleware +++ b/stubs/redux/stub/stub_middleware @@ -39,7 +39,7 @@ List> createStoreStubsMiddleware([ } Middleware _editStub() { - return (Store store, dynamic dynamicAction, NextDispatcher next) async { + return (Store store, dynamic dynamicAction, NextDispatcher next) { final action = dynamicAction as EditStub; @@ -53,12 +53,7 @@ Middleware _editStub() { store.dispatch(UpdateCurrentRoute(StubEditScreen.route)); if (isMobile(action.context)) { - final stub = - await Navigator.of(action.context).pushNamed(StubEditScreen.route); - - if (action.completer != null && stub != null) { - action.completer.complete(stub); - } + action.navigator.pushNamed(QuoteEditScreen.route); } }; }