Code refactor
This commit is contained in:
parent
8128e9e029
commit
126f86e7fb
|
|
@ -78,10 +78,9 @@ class LoadClientActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadClients {
|
class LoadClients {
|
||||||
LoadClients({this.completer, this.force = false});
|
LoadClients({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadClientRequest implements StartLoading {}
|
class LoadClientRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,9 @@ class LoadCompanyGatewayActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadCompanyGateways {
|
class LoadCompanyGateways {
|
||||||
LoadCompanyGateways({this.completer, this.force = false});
|
LoadCompanyGateways({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadCompanyGatewayRequest implements StartLoading {}
|
class LoadCompanyGatewayRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -82,10 +82,9 @@ class LoadCredit {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadCredits {
|
class LoadCredits {
|
||||||
LoadCredits({this.completer, this.force = false});
|
LoadCredits({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadCreditRequest implements StartLoading {}
|
class LoadCreditRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,9 @@ class LoadDesignActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDesigns {
|
class LoadDesigns {
|
||||||
LoadDesigns({this.completer, this.force = false});
|
LoadDesigns({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDesignRequest implements StartLoading {}
|
class LoadDesignRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,9 @@ class LoadDocumentActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDocuments {
|
class LoadDocuments {
|
||||||
LoadDocuments({this.completer, this.force = false});
|
LoadDocuments({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDocumentRequest implements StartLoading {}
|
class LoadDocumentRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,9 @@ class LoadExpenseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadExpenses {
|
class LoadExpenses {
|
||||||
LoadExpenses({this.completer, this.force = false});
|
LoadExpenses({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadExpenseRequest implements StartLoading {}
|
class LoadExpenseRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,9 @@ class LoadGroupActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadGroups {
|
class LoadGroups {
|
||||||
LoadGroups({this.completer, this.force = false});
|
LoadGroups({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadGroupRequest implements StartLoading {}
|
class LoadGroupRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -80,10 +80,9 @@ class LoadInvoice {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadInvoices {
|
class LoadInvoices {
|
||||||
LoadInvoices({this.completer, this.force = false});
|
LoadInvoices({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadInvoiceRequest implements StartLoading {}
|
class LoadInvoiceRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/expense/expense_actions.dart';
|
|
||||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart';
|
import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/product/product_actions.dart';
|
|
||||||
import 'package:invoiceninja_flutter/redux/task/task_actions.dart';
|
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/invoice/invoice_email_vm.dart';
|
import 'package:invoiceninja_flutter/ui/invoice/invoice_email_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
|
import 'package:invoiceninja_flutter/ui/invoice/edit/invoice_edit_vm.dart';
|
||||||
|
|
@ -303,12 +298,7 @@ Middleware<AppState> _markInvoicePaid(InvoiceRepository repository) {
|
||||||
store.state.credentials, action.invoiceIds, EntityAction.markPaid)
|
store.state.credentials, action.invoiceIds, EntityAction.markPaid)
|
||||||
.then((invoices) {
|
.then((invoices) {
|
||||||
store.dispatch(MarkInvoicesPaidSuccess(invoices));
|
store.dispatch(MarkInvoicesPaidSuccess(invoices));
|
||||||
final Completer<Null> completer = Completer<Null>();
|
store.dispatch(RefreshData());
|
||||||
completer.future.then((_) {
|
|
||||||
store.dispatch(LoadPayments(force: true));
|
|
||||||
});
|
|
||||||
store.dispatch(
|
|
||||||
LoadClient(clientId: invoices.first.clientId, completer: completer));
|
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}
|
}
|
||||||
|
|
@ -366,14 +356,7 @@ Middleware<AppState> _saveInvoice(InvoiceRepository repository) {
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(SaveInvoiceSuccess(invoice));
|
store.dispatch(SaveInvoiceSuccess(invoice));
|
||||||
}
|
}
|
||||||
if (invoice.hasTasks) {
|
store.dispatch(RefreshData());
|
||||||
store.dispatch(LoadTasks(force: true));
|
|
||||||
} else if (invoice.hasExpenses) {
|
|
||||||
store.dispatch(LoadExpenses(force: true));
|
|
||||||
} else {
|
|
||||||
// TODO add check if auto-update is enabled
|
|
||||||
store.dispatch(LoadProducts(force: true));
|
|
||||||
}
|
|
||||||
action.completer.complete(invoice);
|
action.completer.complete(invoice);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
print(error);
|
print(error);
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,9 @@ class LoadPaymentActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadPayments {
|
class LoadPayments {
|
||||||
LoadPayments({this.completer, this.force = false});
|
LoadPayments({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadPaymentRequest implements StartLoading {}
|
class LoadPaymentRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
|
||||||
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/payment/refund/payment_refund_vm.dart';
|
import 'package:invoiceninja_flutter/ui/payment/refund/payment_refund_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
import 'package:invoiceninja_flutter/utils/platforms.dart';
|
||||||
|
|
@ -171,7 +170,7 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
|
||||||
store.state.credentials, action.paymentIds, EntityAction.delete)
|
store.state.credentials, action.paymentIds, EntityAction.delete)
|
||||||
.then((List<PaymentEntity> payments) {
|
.then((List<PaymentEntity> payments) {
|
||||||
store.dispatch(DeletePaymentsSuccess(payments));
|
store.dispatch(DeletePaymentsSuccess(payments));
|
||||||
store.dispatch(LoadInvoices(force: true));
|
store.dispatch(RefreshData());
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}
|
}
|
||||||
|
|
@ -198,7 +197,7 @@ Middleware<AppState> _restorePayment(PaymentRepository repository) {
|
||||||
store.state.credentials, action.paymentIds, EntityAction.restore)
|
store.state.credentials, action.paymentIds, EntityAction.restore)
|
||||||
.then((List<PaymentEntity> payments) {
|
.then((List<PaymentEntity> payments) {
|
||||||
store.dispatch(RestorePaymentsSuccess(payments));
|
store.dispatch(RestorePaymentsSuccess(payments));
|
||||||
store.dispatch(LoadInvoices(force: true));
|
store.dispatch(RefreshData());
|
||||||
if (action.completer != null) {
|
if (action.completer != null) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +227,7 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(SavePaymentSuccess(payment));
|
store.dispatch(SavePaymentSuccess(payment));
|
||||||
}
|
}
|
||||||
store.dispatch(LoadInvoices(force: true));
|
store.dispatch(RefreshData());
|
||||||
action.completer.complete(payment);
|
action.completer.complete(payment);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
print(error);
|
print(error);
|
||||||
|
|
@ -251,7 +250,7 @@ Middleware<AppState> _refundPayment(PaymentRepository repository) {
|
||||||
.then((PaymentEntity payment) {
|
.then((PaymentEntity payment) {
|
||||||
store.dispatch(SavePaymentSuccess(payment));
|
store.dispatch(SavePaymentSuccess(payment));
|
||||||
store.dispatch(RefundPaymentSuccess(payment));
|
store.dispatch(RefundPaymentSuccess(payment));
|
||||||
store.dispatch(LoadInvoices(force: true));
|
store.dispatch(RefreshData());
|
||||||
action.completer.complete(payment);
|
action.completer.complete(payment);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
print(error);
|
print(error);
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,9 @@ class LoadPaymentTermActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadPaymentTerms {
|
class LoadPaymentTerms {
|
||||||
LoadPaymentTerms({this.completer, this.force = false});
|
LoadPaymentTerms({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadPaymentTermRequest implements StartLoading {}
|
class LoadPaymentTermRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -51,10 +51,9 @@ class UpdateProduct implements PersistUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProducts {
|
class LoadProducts {
|
||||||
LoadProducts({this.completer, this.force = false});
|
LoadProducts({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProductsRequest implements StartLoading {}
|
class LoadProductsRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,9 @@ class LoadProjectActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProjects {
|
class LoadProjects {
|
||||||
LoadProjects({this.completer, this.force = false});
|
LoadProjects({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProjectRequest implements StartLoading {}
|
class LoadProjectRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -82,10 +82,9 @@ class LoadQuote {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadQuotes {
|
class LoadQuotes {
|
||||||
LoadQuotes({this.completer, this.force = false});
|
LoadQuotes({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadQuoteRequest implements StartLoading {}
|
class LoadQuoteRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
import 'package:invoiceninja_flutter/redux/app/app_middleware.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/credit/credit_actions.dart';
|
import 'package:invoiceninja_flutter/redux/credit/credit_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/invoice/invoice_actions.dart';
|
|
||||||
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
import 'package:invoiceninja_flutter/redux/quote/quote_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_vm.dart';
|
import 'package:invoiceninja_flutter/ui/quote/edit/quote_edit_vm.dart';
|
||||||
|
|
@ -219,7 +218,7 @@ Middleware<AppState> _convertQuote(QuoteRepository repository) {
|
||||||
store.state.credentials, action.quoteIds, EntityAction.convert)
|
store.state.credentials, action.quoteIds, EntityAction.convert)
|
||||||
.then((quotes) {
|
.then((quotes) {
|
||||||
store.dispatch(ConvertQuoteSuccess(quotes: quotes));
|
store.dispatch(ConvertQuoteSuccess(quotes: quotes));
|
||||||
store.dispatch(LoadInvoices(force: true));
|
store.dispatch(RefreshData());
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
print(error);
|
print(error);
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,9 @@ class LoadTaskActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTasks {
|
class LoadTasks {
|
||||||
LoadTasks({this.completer, this.force = false});
|
LoadTasks({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTaskRequest implements StartLoading {}
|
class LoadTaskRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,9 @@ class LoadTaxRateActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTaxRates {
|
class LoadTaxRates {
|
||||||
LoadTaxRates({this.completer, this.force = false});
|
LoadTaxRates({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTaxRateRequest implements StartLoading {}
|
class LoadTaxRateRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,9 @@ class LoadTokenActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTokens {
|
class LoadTokens {
|
||||||
LoadTokens({this.completer, this.force = false});
|
LoadTokens({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadTokenRequest implements StartLoading {}
|
class LoadTokenRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,9 @@ class LoadUserActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadUsers {
|
class LoadUsers {
|
||||||
LoadUsers({this.completer, this.force = false});
|
LoadUsers({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadUserRequest implements StartLoading {}
|
class LoadUserRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,9 @@ class LoadVendorActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadVendors {
|
class LoadVendors {
|
||||||
LoadVendors({this.completer, this.force = false});
|
LoadVendors({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadVendorRequest implements StartLoading {}
|
class LoadVendorRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,9 @@ class LoadWebhookActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadWebhooks {
|
class LoadWebhooks {
|
||||||
LoadWebhooks({this.completer, this.force = false});
|
LoadWebhooks({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadWebhookRequest implements StartLoading {}
|
class LoadWebhookRequest implements StartLoading {}
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,9 @@ class LoadStubActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadStubs {
|
class LoadStubs {
|
||||||
LoadStubs({this.completer, this.force = false});
|
LoadStubs({this.completer});
|
||||||
|
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadStubRequest implements StartLoading {}
|
class LoadStubRequest implements StartLoading {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue