Refactor
This commit is contained in:
parent
e9fae48d10
commit
c8219f855e
|
|
@ -98,11 +98,11 @@ class _InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
||||||
},
|
},
|
||||||
ProductEditScreen.route: (context) => ProductEditScreen(),
|
ProductEditScreen.route: (context) => ProductEditScreen(),
|
||||||
ClientScreen.route: (context) {
|
ClientScreen.route: (context) {
|
||||||
widget.store.dispatch(LoadClientsAction());
|
widget.store.dispatch(LoadClients());
|
||||||
return ClientScreen();
|
return ClientScreen();
|
||||||
},
|
},
|
||||||
InvoiceScreen.route: (context) {
|
InvoiceScreen.route: (context) {
|
||||||
widget.store.dispatch(LoadInvoicesAction());
|
widget.store.dispatch(LoadInvoices());
|
||||||
return InvoiceScreen();
|
return InvoiceScreen();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,95 +1,18 @@
|
||||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja/redux/client/client_actions.dart';
|
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
|
||||||
import 'package:invoiceninja/redux/invoice/invoice_actions.dart';
|
|
||||||
import 'package:invoiceninja/redux/auth/auth_actions.dart';
|
|
||||||
|
|
||||||
final loadingReducer = combineReducers<bool>([
|
final loadingReducer = combineReducers<bool>([
|
||||||
TypedReducer<bool, UserLoginRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, UserLoginSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, UserLoginFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, StartLoading>(_setLoading),
|
TypedReducer<bool, StartLoading>(_setLoading),
|
||||||
TypedReducer<bool, StopLoading>(_setLoaded),
|
TypedReducer<bool, StopLoading>(_setLoaded),
|
||||||
|
|
||||||
//TypedReducer<bool, LoadDashboardRequest>(_setLoading),
|
|
||||||
//TypedReducer<bool, LoadDashboardSuccess>(_setLoaded),
|
|
||||||
//TypedReducer<bool, LoadDashboardFailure>(_setLoaded),
|
|
||||||
|
|
||||||
// Products
|
|
||||||
TypedReducer<bool, LoadProductsRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, LoadProductsSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, LoadProductsFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, SaveProductRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, SaveProductFailure>(_setLoaded),
|
|
||||||
TypedReducer<bool, SaveProductSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, AddProductSuccess>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, ArchiveProductRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, ArchiveProductSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, ArchiveProductFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, DeleteProductRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, DeleteProductSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, DeleteProductFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, RestoreProductRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, RestoreProductSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, RestoreProductFailure>(_setLoaded),
|
|
||||||
|
|
||||||
// Clients
|
|
||||||
TypedReducer<bool, LoadClientsRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, LoadClientsSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, LoadClientsFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, SaveClientRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, SaveClientFailure>(_setLoaded),
|
|
||||||
TypedReducer<bool, SaveClientSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, AddClientSuccess>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, ArchiveClientRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, ArchiveClientSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, ArchiveClientFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, DeleteClientRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, DeleteClientSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, DeleteClientFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, RestoreClientRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, RestoreClientSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, RestoreClientFailure>(_setLoaded),
|
|
||||||
|
|
||||||
// Invoices
|
|
||||||
TypedReducer<bool, LoadInvoicesRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, LoadInvoicesSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, LoadInvoicesFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, SaveInvoiceRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, SaveInvoiceFailure>(_setLoaded),
|
|
||||||
TypedReducer<bool, SaveInvoiceSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, AddInvoiceSuccess>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, ArchiveInvoiceRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, ArchiveInvoiceSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, ArchiveInvoiceFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, DeleteInvoiceRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, DeleteInvoiceSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, DeleteInvoiceFailure>(_setLoaded),
|
|
||||||
|
|
||||||
TypedReducer<bool, RestoreInvoiceRequest>(_setLoading),
|
|
||||||
TypedReducer<bool, RestoreInvoiceSuccess>(_setLoaded),
|
|
||||||
TypedReducer<bool, RestoreInvoiceFailure>(_setLoaded),
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
bool _setLoading(bool state, action) {
|
bool _setLoading(bool state, action) {
|
||||||
|
print('set loading to true');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _setLoaded(bool state, action) {
|
bool _setLoaded(bool state, action) {
|
||||||
|
print('set loading to false');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||||
|
|
||||||
class LoadStateRequest {
|
class LoadStateRequest {
|
||||||
|
|
@ -22,7 +23,7 @@ class UserLoginLoaded {
|
||||||
UserLoginLoaded(this.email, this.password, this.url, this.secret);
|
UserLoginLoaded(this.email, this.password, this.url, this.secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserLoginRequest {
|
class UserLoginRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final String email;
|
final String email;
|
||||||
final String password;
|
final String password;
|
||||||
|
|
@ -32,9 +33,9 @@ class UserLoginRequest {
|
||||||
UserLoginRequest(this.completer, this.email, this.password, this.url, this.secret);
|
UserLoginRequest(this.completer, this.email, this.password, this.url, this.secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserLoginSuccess {}
|
class UserLoginSuccess implements StopLoading {}
|
||||||
|
|
||||||
class UserLoginFailure {
|
class UserLoginFailure implements StopLoading {
|
||||||
final String error;
|
final String error;
|
||||||
|
|
||||||
UserLoginFailure(this.error);
|
UserLoginFailure(this.error);
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@ import 'package:invoiceninja/data/models/models.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
|
|
||||||
class LoadClientsAction {
|
class LoadClients {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
final bool force;
|
||||||
|
|
||||||
LoadClientsAction([this.completer, this.force = false]);
|
LoadClients([this.completer, this.force = false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadClientsRequest {}
|
class LoadClientsRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadClientsFailure {
|
class LoadClientsFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
LoadClientsFailure(this.error);
|
LoadClientsFailure(this.error);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ class LoadClientsFailure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadClientsSuccess implements PersistData {
|
class LoadClientsSuccess implements StopLoading, PersistData {
|
||||||
final BuiltList<ClientEntity> clients;
|
final BuiltList<ClientEntity> clients;
|
||||||
LoadClientsSuccess(this.clients);
|
LoadClientsSuccess(this.clients);
|
||||||
|
|
||||||
|
|
@ -38,74 +38,74 @@ class SelectClientAction {
|
||||||
SelectClientAction(this.client);
|
SelectClientAction(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveClientRequest {
|
class SaveClientRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
SaveClientRequest(this.completer, this.client);
|
SaveClientRequest(this.completer, this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveClientSuccess implements PersistData {
|
class SaveClientSuccess implements StopLoading, PersistData {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
|
|
||||||
SaveClientSuccess(this.client);
|
SaveClientSuccess(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveClientFailure {
|
class SaveClientFailure implements StopLoading {
|
||||||
final String error;
|
final String error;
|
||||||
SaveClientFailure (this.error);
|
SaveClientFailure (this.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveClientRequest {
|
class ArchiveClientRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int clientId;
|
final int clientId;
|
||||||
|
|
||||||
ArchiveClientRequest(this.completer, this.clientId);
|
ArchiveClientRequest(this.completer, this.clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveClientSuccess implements PersistData {
|
class ArchiveClientSuccess implements StopLoading, PersistData {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
ArchiveClientSuccess(this.client);
|
ArchiveClientSuccess(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveClientFailure {
|
class ArchiveClientFailure implements StopLoading {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
ArchiveClientFailure(this.client);
|
ArchiveClientFailure(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteClientRequest {
|
class DeleteClientRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int clientId;
|
final int clientId;
|
||||||
|
|
||||||
DeleteClientRequest(this.completer, this.clientId);
|
DeleteClientRequest(this.completer, this.clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteClientSuccess implements PersistData {
|
class DeleteClientSuccess implements StopLoading, PersistData {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
DeleteClientSuccess(this.client);
|
DeleteClientSuccess(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteClientFailure {
|
class DeleteClientFailure implements StopLoading {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
DeleteClientFailure(this.client);
|
DeleteClientFailure(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreClientRequest {
|
class RestoreClientRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int clientId;
|
final int clientId;
|
||||||
RestoreClientRequest(this.completer, this.clientId);
|
RestoreClientRequest(this.completer, this.clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreClientSuccess implements PersistData {
|
class RestoreClientSuccess implements StopLoading, PersistData {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
RestoreClientSuccess(this.client);
|
RestoreClientSuccess(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreClientFailure {
|
class RestoreClientFailure implements StopLoading {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
RestoreClientFailure(this.client);
|
RestoreClientFailure(this.client);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddClientSuccess implements PersistData {
|
class AddClientSuccess implements StopLoading, PersistData {
|
||||||
final ClientEntity client;
|
final ClientEntity client;
|
||||||
AddClientSuccess(this.client);
|
AddClientSuccess(this.client);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
|
||||||
final restoreClient = _restoreClient(repository);
|
final restoreClient = _restoreClient(repository);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
TypedMiddleware<AppState, LoadClientsAction>(loadClients),
|
TypedMiddleware<AppState, LoadClients>(loadClients),
|
||||||
TypedMiddleware<AppState, SaveClientRequest>(saveClient),
|
TypedMiddleware<AppState, SaveClientRequest>(saveClient),
|
||||||
TypedMiddleware<AppState, ArchiveClientRequest>(archiveClient),
|
TypedMiddleware<AppState, ArchiveClientRequest>(archiveClient),
|
||||||
TypedMiddleware<AppState, DeleteClientRequest>(deleteClient),
|
TypedMiddleware<AppState, DeleteClientRequest>(deleteClient),
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ class LoadDashboardAction {
|
||||||
LoadDashboardAction([this.completer, this.force = false]);
|
LoadDashboardAction([this.completer, this.force = false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDashboardRequest {}
|
class LoadDashboardRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadDashboardFailure {
|
class LoadDashboardFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
|
|
||||||
LoadDashboardFailure(this.error);
|
LoadDashboardFailure(this.error);
|
||||||
|
|
@ -23,7 +23,7 @@ class LoadDashboardFailure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadDashboardSuccess implements PersistData {
|
class LoadDashboardSuccess implements StopLoading, PersistData {
|
||||||
final DashboardEntity data;
|
final DashboardEntity data;
|
||||||
|
|
||||||
LoadDashboardSuccess(this.data);
|
LoadDashboardSuccess(this.data);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ Middleware<AppState> _createLoadDashboard(DashboardRepository repository) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}
|
}
|
||||||
if (state.clientState.isStale) {
|
if (state.clientState.isStale) {
|
||||||
store.dispatch(LoadClientsAction());
|
store.dispatch(LoadClients());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).catchError((error) => store.dispatch(LoadDashboardFailure(error)));
|
).catchError((error) => store.dispatch(LoadDashboardFailure(error)));
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,16 @@ import 'package:invoiceninja/data/models/models.dart';
|
||||||
import 'package:built_collection/built_collection.dart';
|
import 'package:built_collection/built_collection.dart';
|
||||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||||
|
|
||||||
class LoadInvoicesAction {
|
class LoadInvoices {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final bool force;
|
final bool force;
|
||||||
|
|
||||||
LoadInvoicesAction([this.completer, this.force = false]);
|
LoadInvoices([this.completer, this.force = false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadInvoicesRequest {}
|
class LoadInvoicesRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadInvoicesFailure {
|
class LoadInvoicesFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
LoadInvoicesFailure(this.error);
|
LoadInvoicesFailure(this.error);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ class LoadInvoicesFailure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadInvoicesSuccess implements PersistData {
|
class LoadInvoicesSuccess implements StopLoading, PersistData {
|
||||||
final BuiltList<InvoiceEntity> invoices;
|
final BuiltList<InvoiceEntity> invoices;
|
||||||
LoadInvoicesSuccess(this.invoices);
|
LoadInvoicesSuccess(this.invoices);
|
||||||
|
|
||||||
|
|
@ -38,74 +38,74 @@ class SelectInvoiceAction {
|
||||||
SelectInvoiceAction(this.invoice);
|
SelectInvoiceAction(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveInvoiceRequest {
|
class SaveInvoiceRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
SaveInvoiceRequest(this.completer, this.invoice);
|
SaveInvoiceRequest(this.completer, this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveInvoiceSuccess implements PersistData {
|
class SaveInvoiceSuccess implements StopLoading, PersistData {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
|
|
||||||
SaveInvoiceSuccess(this.invoice);
|
SaveInvoiceSuccess(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveInvoiceFailure {
|
class SaveInvoiceFailure implements StopLoading {
|
||||||
final String error;
|
final String error;
|
||||||
SaveInvoiceFailure (this.error);
|
SaveInvoiceFailure (this.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveInvoiceRequest {
|
class ArchiveInvoiceRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int invoiceId;
|
final int invoiceId;
|
||||||
|
|
||||||
ArchiveInvoiceRequest(this.completer, this.invoiceId);
|
ArchiveInvoiceRequest(this.completer, this.invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveInvoiceSuccess implements PersistData {
|
class ArchiveInvoiceSuccess implements StopLoading, PersistData {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
ArchiveInvoiceSuccess(this.invoice);
|
ArchiveInvoiceSuccess(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveInvoiceFailure {
|
class ArchiveInvoiceFailure implements StopLoading {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
ArchiveInvoiceFailure(this.invoice);
|
ArchiveInvoiceFailure(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteInvoiceRequest {
|
class DeleteInvoiceRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int invoiceId;
|
final int invoiceId;
|
||||||
|
|
||||||
DeleteInvoiceRequest(this.completer, this.invoiceId);
|
DeleteInvoiceRequest(this.completer, this.invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteInvoiceSuccess implements PersistData {
|
class DeleteInvoiceSuccess implements StopLoading, PersistData {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
DeleteInvoiceSuccess(this.invoice);
|
DeleteInvoiceSuccess(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteInvoiceFailure {
|
class DeleteInvoiceFailure implements StopLoading {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
DeleteInvoiceFailure(this.invoice);
|
DeleteInvoiceFailure(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreInvoiceRequest {
|
class RestoreInvoiceRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int invoiceId;
|
final int invoiceId;
|
||||||
RestoreInvoiceRequest(this.completer, this.invoiceId);
|
RestoreInvoiceRequest(this.completer, this.invoiceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreInvoiceSuccess implements PersistData {
|
class RestoreInvoiceSuccess implements StopLoading, PersistData {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
RestoreInvoiceSuccess(this.invoice);
|
RestoreInvoiceSuccess(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreInvoiceFailure {
|
class RestoreInvoiceFailure implements StopLoading {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
RestoreInvoiceFailure(this.invoice);
|
RestoreInvoiceFailure(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddInvoiceSuccess implements PersistData {
|
class AddInvoiceSuccess implements StopLoading, PersistData {
|
||||||
final InvoiceEntity invoice;
|
final InvoiceEntity invoice;
|
||||||
AddInvoiceSuccess(this.invoice);
|
AddInvoiceSuccess(this.invoice);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
|
||||||
final restoreInvoice = _restoreInvoice(repository);
|
final restoreInvoice = _restoreInvoice(repository);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
TypedMiddleware<AppState, LoadInvoicesAction>(loadInvoices),
|
TypedMiddleware<AppState, LoadInvoices>(loadInvoices),
|
||||||
TypedMiddleware<AppState, SaveInvoiceRequest>(saveInvoice),
|
TypedMiddleware<AppState, SaveInvoiceRequest>(saveInvoice),
|
||||||
TypedMiddleware<AppState, ArchiveInvoiceRequest>(archiveInvoice),
|
TypedMiddleware<AppState, ArchiveInvoiceRequest>(archiveInvoice),
|
||||||
TypedMiddleware<AppState, DeleteInvoiceRequest>(deleteInvoice),
|
TypedMiddleware<AppState, DeleteInvoiceRequest>(deleteInvoice),
|
||||||
|
|
@ -128,7 +128,7 @@ Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
|
||||||
action.completer.complete(null);
|
action.completer.complete(null);
|
||||||
}
|
}
|
||||||
if (state.clientState.isStale) {
|
if (state.clientState.isStale) {
|
||||||
store.dispatch(LoadClientsAction());
|
store.dispatch(LoadClients());
|
||||||
}
|
}
|
||||||
}).catchError((error) => store.dispatch(LoadInvoicesFailure(error)));
|
}).catchError((error) => store.dispatch(LoadInvoicesFailure(error)));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ class LoadProducts {
|
||||||
LoadProducts([this.completer, this.force = false]);
|
LoadProducts([this.completer, this.force = false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProductsRequest {}
|
class LoadProductsRequest implements StartLoading {}
|
||||||
|
|
||||||
class LoadProductsFailure {
|
class LoadProductsFailure implements StopLoading {
|
||||||
final dynamic error;
|
final dynamic error;
|
||||||
LoadProductsFailure(this.error);
|
LoadProductsFailure(this.error);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ class LoadProductsFailure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoadProductsSuccess implements PersistData {
|
class LoadProductsSuccess implements PersistData, StopLoading {
|
||||||
final BuiltList<ProductEntity> products;
|
final BuiltList<ProductEntity> products;
|
||||||
LoadProductsSuccess(this.products);
|
LoadProductsSuccess(this.products);
|
||||||
|
|
||||||
|
|
@ -39,78 +39,78 @@ class EditProduct {
|
||||||
EditProduct({this.product, this.context});
|
EditProduct({this.product, this.context});
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveProductRequest {
|
class SaveProductRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
SaveProductRequest(this.completer, this.product);
|
SaveProductRequest(this.completer, this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveProductSuccess implements PersistData {
|
class SaveProductSuccess implements StopLoading, PersistData {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
|
|
||||||
SaveProductSuccess(this.product);
|
SaveProductSuccess(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveProductFailure {
|
class AddProductSuccess implements StopLoading, PersistData {
|
||||||
|
final ProductEntity product;
|
||||||
|
AddProductSuccess(this.product);
|
||||||
|
}
|
||||||
|
|
||||||
|
class SaveProductFailure implements StopLoading {
|
||||||
final String error;
|
final String error;
|
||||||
SaveProductFailure (this.error);
|
SaveProductFailure (this.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveProductRequest {
|
class ArchiveProductRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int productId;
|
final int productId;
|
||||||
|
|
||||||
ArchiveProductRequest(this.completer, this.productId);
|
ArchiveProductRequest(this.completer, this.productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveProductSuccess implements PersistData {
|
class ArchiveProductSuccess implements StopLoading, PersistData {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
ArchiveProductSuccess(this.product);
|
ArchiveProductSuccess(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveProductFailure {
|
class ArchiveProductFailure implements StopLoading {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
ArchiveProductFailure(this.product);
|
ArchiveProductFailure(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteProductRequest {
|
class DeleteProductRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int productId;
|
final int productId;
|
||||||
|
|
||||||
DeleteProductRequest(this.completer, this.productId);
|
DeleteProductRequest(this.completer, this.productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteProductSuccess implements PersistData {
|
class DeleteProductSuccess implements StopLoading, PersistData {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
DeleteProductSuccess(this.product);
|
DeleteProductSuccess(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteProductFailure {
|
class DeleteProductFailure implements StopLoading {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
DeleteProductFailure(this.product);
|
DeleteProductFailure(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreProductRequest {
|
class RestoreProductRequest implements StartLoading {
|
||||||
final Completer completer;
|
final Completer completer;
|
||||||
final int productId;
|
final int productId;
|
||||||
RestoreProductRequest(this.completer, this.productId);
|
RestoreProductRequest(this.completer, this.productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreProductSuccess implements PersistData {
|
class RestoreProductSuccess implements StopLoading, PersistData {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
RestoreProductSuccess(this.product);
|
RestoreProductSuccess(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RestoreProductFailure {
|
class RestoreProductFailure implements StopLoading {
|
||||||
final ProductEntity product;
|
final ProductEntity product;
|
||||||
RestoreProductFailure(this.product);
|
RestoreProductFailure(this.product);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddProductSuccess implements PersistData {
|
|
||||||
final ProductEntity product;
|
|
||||||
AddProductSuccess(this.product);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class SearchProducts {
|
class SearchProducts {
|
||||||
final String search;
|
final String search;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class ClientListVM {
|
||||||
static ClientListVM fromStore(Store<AppState> store) {
|
static ClientListVM fromStore(Store<AppState> store) {
|
||||||
Future<Null> _handleRefresh(BuildContext context) {
|
Future<Null> _handleRefresh(BuildContext context) {
|
||||||
final Completer<Null> completer = new Completer<Null>();
|
final Completer<Null> completer = new Completer<Null>();
|
||||||
store.dispatch(LoadClientsAction(completer, true));
|
store.dispatch(LoadClients(completer, true));
|
||||||
return completer.future.then((_) {
|
return completer.future.then((_) {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: SnackBarRow(
|
content: SnackBarRow(
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class InvoiceListVM {
|
||||||
static InvoiceListVM fromStore(Store<AppState> store) {
|
static InvoiceListVM fromStore(Store<AppState> store) {
|
||||||
Future<Null> _handleRefresh(BuildContext context) {
|
Future<Null> _handleRefresh(BuildContext context) {
|
||||||
final Completer<Null> completer = new Completer<Null>();
|
final Completer<Null> completer = new Completer<Null>();
|
||||||
store.dispatch(LoadInvoicesAction(completer, true));
|
store.dispatch(LoadInvoices(completer, true));
|
||||||
return completer.future.then((_) {
|
return completer.future.then((_) {
|
||||||
Scaffold.of(context).showSnackBar(SnackBar(
|
Scaffold.of(context).showSnackBar(SnackBar(
|
||||||
content: SnackBarRow(
|
content: SnackBarRow(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue