Refactor to limit use of dynamic

This commit is contained in:
Hillel Coren 2019-08-18 23:12:05 +03:00
parent 28c791734a
commit ae2e82c1a0
28 changed files with 400 additions and 215 deletions

View File

@ -149,7 +149,8 @@ Middleware<AppState> _createLoadState(
CompanyState company4State; CompanyState company4State;
CompanyState company5State; CompanyState company5State;
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as LoadStateRequest;
try { try {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final appVersion = prefs.getString(kSharedPrefAppVersion); final appVersion = prefs.getString(kSharedPrefAppVersion);
@ -284,11 +285,12 @@ Middleware<AppState> _createUserLoggedIn(
PersistenceRepository company4Repository, PersistenceRepository company4Repository,
PersistenceRepository company5Repository, PersistenceRepository company5Repository,
) { ) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as UserLoginSuccess;
next(action); next(action);
final state = store.state; final state = store.state;
authRepository.saveAuthState(state.authState); authRepository.saveAuthState(state.authState);
uiRepository.saveUIState(state.uiState); uiRepository.saveUIState(state.uiState);
staticRepository.saveStaticState(state.staticState); staticRepository.saveStaticState(state.staticState);
@ -301,7 +303,9 @@ Middleware<AppState> _createUserLoggedIn(
} }
Middleware<AppState> _createPersistUI(PersistenceRepository uiRepository) { Middleware<AppState> _createPersistUI(PersistenceRepository uiRepository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as PersistUI;
next(action); next(action);
uiRepository.saveUIState(store.state.uiState); uiRepository.saveUIState(store.state.uiState);
@ -309,7 +313,8 @@ Middleware<AppState> _createPersistUI(PersistenceRepository uiRepository) {
} }
Middleware<AppState> _createAccountLoaded() { Middleware<AppState> _createAccountLoaded() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as LoadAccountSuccess;
final dynamic data = action.loginResponse; final dynamic data = action.loginResponse;
store.dispatch(LoadStaticSuccess(data: data.static, version: data.version)); store.dispatch(LoadStaticSuccess(data: data.static, version: data.version));
@ -336,7 +341,9 @@ Middleware<AppState> _createAccountLoaded() {
Middleware<AppState> _createPersistStatic( Middleware<AppState> _createPersistStatic(
PersistenceRepository staticRepository) { PersistenceRepository staticRepository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as PersistStatic;
// first process the action so the data is in the state // first process the action so the data is in the state
next(action); next(action);
@ -351,8 +358,9 @@ Middleware<AppState> _createPersistData(
PersistenceRepository company4Repository, PersistenceRepository company4Repository,
PersistenceRepository company5Repository, PersistenceRepository company5Repository,
) { ) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
// first process the action so the data is in the state final action = dynamicAction as PersistData;
next(action); next(action);
final AppState state = store.state; final AppState state = store.state;
@ -387,7 +395,7 @@ Middleware<AppState> _createDeleteState(
PersistenceRepository company4Repository, PersistenceRepository company4Repository,
PersistenceRepository company5Repository, PersistenceRepository company5Repository,
) { ) {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
authRepository.delete(); authRepository.delete();
uiRepository.delete(); uiRepository.delete();
staticRepository.delete(); staticRepository.delete();
@ -397,6 +405,7 @@ Middleware<AppState> _createDeleteState(
company4Repository.delete(); company4Repository.delete();
company5Repository.delete(); company5Repository.delete();
final action = dynamicAction as UserLogout;
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
@ -408,7 +417,9 @@ Middleware<AppState> _createDeleteState(
} }
Middleware<AppState> _createViewMainScreen() { Middleware<AppState> _createViewMainScreen() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewMainScreen;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(DashboardScreen.route)); store.dispatch(UpdateCurrentRoute(DashboardScreen.route));

View File

@ -26,17 +26,17 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
]; ];
} }
void _saveAuthLocal(dynamic action) async { void _saveAuthLocal({String email, String url, String secret}) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString(kSharedPrefEmail, action.email ?? ''); prefs.setString(kSharedPrefEmail, email ?? '');
if (formatApiUrlReadable(action.url) != kAppUrl) { if (formatApiUrlReadable(url) != kAppUrl) {
prefs.setString(kSharedPrefUrl, formatApiUrlMachine(action.url)); prefs.setString(kSharedPrefUrl, formatApiUrlMachine(url));
prefs.setString(kSharedPrefSecret, action.secret); prefs.setString(kSharedPrefSecret, secret);
} }
} }
void _loadAuthLocal(Store<AppState> store, dynamic action) async { void _loadAuthLocal(Store<AppState> store) async {
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
final String email = prefs.getString(kSharedPrefEmail) ?? ''; final String email = prefs.getString(kSharedPrefEmail) ?? '';
final String url = formatApiUrlMachine(prefs.getString(kSharedPrefUrl) ?? ''); final String url = formatApiUrlMachine(prefs.getString(kSharedPrefUrl) ?? '');
@ -55,8 +55,10 @@ void _loadAuthLocal(Store<AppState> store, dynamic action) async {
} }
Middleware<AppState> _createLoginInit() { Middleware<AppState> _createLoginInit() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
_loadAuthLocal(store, action); final action = dynamicAction as LoadUserLogin;
_loadAuthLocal(store);
Navigator.of(action.context).pushReplacementNamed(LoginScreen.route); Navigator.of(action.context).pushReplacementNamed(LoginScreen.route);
@ -65,7 +67,9 @@ Middleware<AppState> _createLoginInit() {
} }
Middleware<AppState> _createLoginRequest(AuthRepository repository) { Middleware<AppState> _createLoginRequest(AuthRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as UserLoginRequest;
repository repository
.login( .login(
email: action.email, email: action.email,
@ -75,7 +79,11 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
platform: action.platform, platform: action.platform,
oneTimePassword: action.oneTimePassword) oneTimePassword: action.oneTimePassword)
.then((data) { .then((data) {
_saveAuthLocal(action); _saveAuthLocal(
email: action.email,
secret: action.secret,
url: action.url,
);
if (_isVersionSupported(data.version)) { if (_isVersionSupported(data.version)) {
store.dispatch(LoadAccountSuccess( store.dispatch(LoadAccountSuccess(
@ -91,7 +99,7 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
message = 'Please check the URL is correct'; message = 'Please check the URL is correct';
} else if (message.toLowerCase().contains('credentials')) { } else if (message.toLowerCase().contains('credentials')) {
message += ', please confirm your credentials in the web app'; message += ', please confirm your credentials in the web app';
} else if (message.contains('404')){ } else if (message.contains('404')) {
message += ', you may need to add /public to the URL'; message += ', you may need to add /public to the URL';
} }
store.dispatch(UserLoginFailure(message)); store.dispatch(UserLoginFailure(message));
@ -102,7 +110,9 @@ Middleware<AppState> _createLoginRequest(AuthRepository repository) {
} }
Middleware<AppState> _createOAuthRequest(AuthRepository repository) { Middleware<AppState> _createOAuthRequest(AuthRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as OAuthLoginRequest;
repository repository
.oauthLogin( .oauthLogin(
token: action.token, token: action.token,
@ -110,7 +120,11 @@ Middleware<AppState> _createOAuthRequest(AuthRepository repository) {
secret: action.secret, secret: action.secret,
platform: action.platform) platform: action.platform)
.then((data) { .then((data) {
_saveAuthLocal(action); _saveAuthLocal(
email: action.email,
secret: action.secret,
url: action.url,
);
if (_isVersionSupported(data.version)) { if (_isVersionSupported(data.version)) {
store.dispatch(LoadAccountSuccess( store.dispatch(LoadAccountSuccess(
@ -129,10 +143,13 @@ Middleware<AppState> _createOAuthRequest(AuthRepository repository) {
} }
Middleware<AppState> _createRefreshRequest(AuthRepository repository) { Middleware<AppState> _createRefreshRequest(AuthRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {
final action = dynamicAction as RefreshData;
next(action); next(action);
_loadAuthLocal(store, action); _loadAuthLocal(store);
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
final String url = final String url =

View File

@ -39,7 +39,9 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
} }
Middleware<AppState> _editClient() { Middleware<AppState> _editClient() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditClient;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -61,7 +63,9 @@ Middleware<AppState> _editClient() {
} }
Middleware<AppState> _viewClient() { Middleware<AppState> _viewClient() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewClient;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -77,7 +81,9 @@ Middleware<AppState> _viewClient() {
} }
Middleware<AppState> _viewClientList() { Middleware<AppState> _viewClientList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewClientList;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -94,7 +100,8 @@ Middleware<AppState> _viewClientList() {
} }
Middleware<AppState> _archiveClient(ClientRepository repository) { Middleware<AppState> _archiveClient(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveClientRequest;
final origClient = store.state.clientState.map[action.clientId]; final origClient = store.state.clientState.map[action.clientId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -117,7 +124,8 @@ Middleware<AppState> _archiveClient(ClientRepository repository) {
} }
Middleware<AppState> _deleteClient(ClientRepository repository) { Middleware<AppState> _deleteClient(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteClientRequest;
final origClient = store.state.clientState.map[action.clientId]; final origClient = store.state.clientState.map[action.clientId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -140,7 +148,8 @@ Middleware<AppState> _deleteClient(ClientRepository repository) {
} }
Middleware<AppState> _restoreClient(ClientRepository repository) { Middleware<AppState> _restoreClient(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreClientRequest;
final origClient = store.state.clientState.map[action.clientId]; final origClient = store.state.clientState.map[action.clientId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -163,7 +172,8 @@ Middleware<AppState> _restoreClient(ClientRepository repository) {
} }
Middleware<AppState> _saveClient(ClientRepository repository) { Middleware<AppState> _saveClient(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveClientRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.client) store.state.selectedCompany, store.state.authState, action.client)
@ -191,7 +201,8 @@ Middleware<AppState> _saveClient(ClientRepository repository) {
} }
Middleware<AppState> _loadClient(ClientRepository repository) { Middleware<AppState> _loadClient(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadClient;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -222,8 +233,9 @@ Middleware<AppState> _loadClient(ClientRepository repository) {
} }
Middleware<AppState> _loadClients(ClientRepository repository) { Middleware<AppState> _loadClients(ClientRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final AppState state = store.state; final AppState state = store.state;
final action = dynamicAction as LoadClients;
if (!state.clientState.isStale && !action.force) { if (!state.clientState.isStale && !action.force) {
next(action); next(action);

View File

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/data/models/models.dart';
import 'package:invoiceninja_flutter/redux/company/company_actions.dart'; import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
import 'package:invoiceninja_flutter/redux/ui/entity_ui_state.dart'; import 'package:invoiceninja_flutter/redux/ui/entity_ui_state.dart';
@ -19,66 +18,71 @@ EntityUIState clientUIReducer(ClientUIState state, dynamic action) {
} }
final saveCompleterReducer = combineReducers<Completer<SelectableEntity>>([ final saveCompleterReducer = combineReducers<Completer<SelectableEntity>>([
TypedReducer<Completer<SelectableEntity>, EditClient>(editClient), TypedReducer<Completer<SelectableEntity>, EditClient>((completer, action) {
]);
Completer<SelectableEntity> editClient(
Completer<SelectableEntity> completer, dynamic action) {
return action.completer; return action.completer;
} }),
]);
final editingContactReducer = combineReducers<ContactEntity>([ final editingContactReducer = combineReducers<ContactEntity>([
TypedReducer<ContactEntity, EditClient>(editContact), TypedReducer<ContactEntity, EditClient>((contact, action) {
TypedReducer<ContactEntity, EditContact>(editContact), return action.contact ?? ContactEntity();
}),
TypedReducer<ContactEntity, EditContact>((contact, action) {
return action.contact ?? ContactEntity();
}),
]); ]);
ContactEntity editContact(ContactEntity contact, dynamic action) { final selectedIdReducer = combineReducers<int>([
return action.contact ?? ContactEntity(); TypedReducer<int, ViewClient>((selectedId, action) {
} return action.clientId;
}),
Reducer<int> selectedIdReducer = combineReducers([ TypedReducer<int, AddClientSuccess>((selectedId, action) {
TypedReducer<int, ViewClient>( return action.client.id;
(int selectedId, dynamic action) => action.clientId), }),
TypedReducer<int, AddClientSuccess>(
(int selectedId, dynamic action) => action.client.id),
]); ]);
final editingReducer = combineReducers<ClientEntity>([ final editingReducer = combineReducers<ClientEntity>([
TypedReducer<ClientEntity, SaveClientSuccess>(_updateEditing), TypedReducer<ClientEntity, SaveClientSuccess>((client, action) {
TypedReducer<ClientEntity, AddClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, RestoreClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, ArchiveClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, DeleteClientSuccess>(_updateEditing),
TypedReducer<ClientEntity, EditClient>(_updateEditing),
TypedReducer<ClientEntity, UpdateClient>(_updateEditing),
TypedReducer<ClientEntity, AddContact>(_addContact),
TypedReducer<ClientEntity, DeleteContact>(_removeContact),
TypedReducer<ClientEntity, UpdateContact>(_updateContact),
TypedReducer<ClientEntity, ViewClient>(_clearEditing),
TypedReducer<ClientEntity, ViewClientList>(_clearEditing),
TypedReducer<ClientEntity, SelectCompany>(_clearEditing),
]);
ClientEntity _clearEditing(ClientEntity client, dynamic action) {
return ClientEntity();
}
ClientEntity _updateEditing(ClientEntity client, dynamic action) {
return action.client; return action.client;
} }),
TypedReducer<ClientEntity, AddClientSuccess>((client, action) {
ClientEntity _addContact(ClientEntity client, AddContact action) { return action.client;
}),
TypedReducer<ClientEntity, RestoreClientSuccess>((client, action) {
return action.client;
}),
TypedReducer<ClientEntity, ArchiveClientSuccess>((client, action) {
return action.client;
}),
TypedReducer<ClientEntity, DeleteClientSuccess>((client, action) {
return action.client;
}),
TypedReducer<ClientEntity, EditClient>((client, action) {
return action.client;
}),
TypedReducer<ClientEntity, UpdateClient>((client, action) {
return action.client;
}),
TypedReducer<ClientEntity, AddContact>((client, action) {
return client return client
.rebuild((b) => b..contacts.add(action.contact ?? ContactEntity())); .rebuild((b) => b..contacts.add(action.contact ?? ContactEntity()));
} }),
TypedReducer<ClientEntity, DeleteContact>((client, action) {
ClientEntity _removeContact(ClientEntity client, DeleteContact action) {
return client.rebuild((b) => b..contacts.removeAt(action.index)); return client.rebuild((b) => b..contacts.removeAt(action.index));
} }),
TypedReducer<ClientEntity, UpdateContact>((client, action) {
ClientEntity _updateContact(ClientEntity client, UpdateContact action) {
return client.rebuild((b) => b..contacts[action.index] = action.contact); return client.rebuild((b) => b..contacts[action.index] = action.contact);
} }),
TypedReducer<ClientEntity, ViewClient>((client, action) {
return ClientEntity();
}),
TypedReducer<ClientEntity, ViewClientList>((client, action) {
return ClientEntity();
}),
TypedReducer<ClientEntity, SelectCompany>((client, action) {
return ClientEntity();
}),
]);
final clientListReducer = combineReducers<ListUIState>([ final clientListReducer = combineReducers<ListUIState>([
TypedReducer<ListUIState, SortClients>(_sortClients), TypedReducer<ListUIState, SortClients>(_sortClients),

View File

@ -58,6 +58,7 @@ abstract class ClientUIState extends Object
editingContact: ContactEntity(), editingContact: ContactEntity(),
selectedId: 0, selectedId: 0,
saveCompleter: null, saveCompleter: null,
cancelCompleter: null,
); );
} }
ClientUIState._(); ClientUIState._();
@ -72,6 +73,10 @@ abstract class ClientUIState extends Object
@BuiltValueField(serialize: false) @BuiltValueField(serialize: false)
Completer<SelectableEntity> get saveCompleter; Completer<SelectableEntity> get saveCompleter;
@nullable
@BuiltValueField(serialize: false)
Completer<Null> get cancelCompleter;
@override @override
bool get isCreatingNew => editing.isNew; bool get isCreatingNew => editing.isNew;

View File

@ -266,6 +266,8 @@ class _$ClientUIState extends ClientUIState {
@override @override
final Completer<SelectableEntity> saveCompleter; final Completer<SelectableEntity> saveCompleter;
@override @override
final Completer<Null> cancelCompleter;
@override
final int selectedId; final int selectedId;
@override @override
final ListUIState listUIState; final ListUIState listUIState;
@ -277,6 +279,7 @@ class _$ClientUIState extends ClientUIState {
{this.editing, {this.editing,
this.editingContact, this.editingContact,
this.saveCompleter, this.saveCompleter,
this.cancelCompleter,
this.selectedId, this.selectedId,
this.listUIState}) this.listUIState})
: super._() { : super._() {
@ -302,6 +305,7 @@ class _$ClientUIState extends ClientUIState {
editing == other.editing && editing == other.editing &&
editingContact == other.editingContact && editingContact == other.editingContact &&
saveCompleter == other.saveCompleter && saveCompleter == other.saveCompleter &&
cancelCompleter == other.cancelCompleter &&
selectedId == other.selectedId && selectedId == other.selectedId &&
listUIState == other.listUIState; listUIState == other.listUIState;
} }
@ -309,9 +313,11 @@ class _$ClientUIState extends ClientUIState {
@override @override
int get hashCode { int get hashCode {
return $jf($jc( return $jf($jc(
$jc(
$jc( $jc(
$jc($jc($jc(0, editing.hashCode), editingContact.hashCode), $jc($jc($jc(0, editing.hashCode), editingContact.hashCode),
saveCompleter.hashCode), saveCompleter.hashCode),
cancelCompleter.hashCode),
selectedId.hashCode), selectedId.hashCode),
listUIState.hashCode)); listUIState.hashCode));
} }
@ -322,6 +328,7 @@ class _$ClientUIState extends ClientUIState {
..add('editing', editing) ..add('editing', editing)
..add('editingContact', editingContact) ..add('editingContact', editingContact)
..add('saveCompleter', saveCompleter) ..add('saveCompleter', saveCompleter)
..add('cancelCompleter', cancelCompleter)
..add('selectedId', selectedId) ..add('selectedId', selectedId)
..add('listUIState', listUIState)) ..add('listUIState', listUIState))
.toString(); .toString();
@ -348,6 +355,11 @@ class ClientUIStateBuilder
set saveCompleter(Completer<SelectableEntity> saveCompleter) => set saveCompleter(Completer<SelectableEntity> saveCompleter) =>
_$this._saveCompleter = saveCompleter; _$this._saveCompleter = saveCompleter;
Completer<Null> _cancelCompleter;
Completer<Null> get cancelCompleter => _$this._cancelCompleter;
set cancelCompleter(Completer<Null> cancelCompleter) =>
_$this._cancelCompleter = cancelCompleter;
int _selectedId; int _selectedId;
int get selectedId => _$this._selectedId; int get selectedId => _$this._selectedId;
set selectedId(int selectedId) => _$this._selectedId = selectedId; set selectedId(int selectedId) => _$this._selectedId = selectedId;
@ -365,6 +377,7 @@ class ClientUIStateBuilder
_editing = _$v.editing?.toBuilder(); _editing = _$v.editing?.toBuilder();
_editingContact = _$v.editingContact?.toBuilder(); _editingContact = _$v.editingContact?.toBuilder();
_saveCompleter = _$v.saveCompleter; _saveCompleter = _$v.saveCompleter;
_cancelCompleter = _$v.cancelCompleter;
_selectedId = _$v.selectedId; _selectedId = _$v.selectedId;
_listUIState = _$v.listUIState?.toBuilder(); _listUIState = _$v.listUIState?.toBuilder();
_$v = null; _$v = null;
@ -394,6 +407,7 @@ class ClientUIStateBuilder
editing: _editing?.build(), editing: _editing?.build(),
editingContact: _editingContact?.build(), editingContact: _editingContact?.build(),
saveCompleter: saveCompleter, saveCompleter: saveCompleter,
cancelCompleter: cancelCompleter,
selectedId: selectedId, selectedId: selectedId,
listUIState: listUIState.build()); listUIState: listUIState.build());
} catch (_) { } catch (_) {

View File

@ -22,7 +22,8 @@ List<Middleware<AppState>> createStoreDashboardMiddleware([
} }
Middleware<AppState> _createViewDashboard() { Middleware<AppState> _createViewDashboard() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewDashboard;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
@ -41,7 +42,8 @@ Middleware<AppState> _createViewDashboard() {
} }
Middleware<AppState> _createLoadDashboard(DashboardRepository repository) { Middleware<AppState> _createLoadDashboard(DashboardRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadDashboard;
final state = store.state; final state = store.state;
if (!state.dashboardState.isStale && !action.force) { if (!state.dashboardState.isStale && !action.force) {

View File

@ -38,7 +38,9 @@ List<Middleware<AppState>> createStoreDocumentsMiddleware([
} }
Middleware<AppState> _editDocument() { Middleware<AppState> _editDocument() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditDocument;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(DocumentEditScreen.route)); store.dispatch(UpdateCurrentRoute(DocumentEditScreen.route));
@ -52,7 +54,9 @@ Middleware<AppState> _editDocument() {
} }
Middleware<AppState> _viewDocument() { Middleware<AppState> _viewDocument() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewDocument;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(DocumentViewScreen.route)); store.dispatch(UpdateCurrentRoute(DocumentViewScreen.route));
@ -61,7 +65,9 @@ Middleware<AppState> _viewDocument() {
} }
Middleware<AppState> _viewDocumentList() { Middleware<AppState> _viewDocumentList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewDocumentList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(DocumentScreen.route)); store.dispatch(UpdateCurrentRoute(DocumentScreen.route));
@ -72,7 +78,8 @@ Middleware<AppState> _viewDocumentList() {
} }
Middleware<AppState> _archiveDocument(DocumentRepository repository) { Middleware<AppState> _archiveDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveDocumentRequest;
final origDocument = store.state.documentState.map[action.documentId]; final origDocument = store.state.documentState.map[action.documentId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -95,7 +102,8 @@ Middleware<AppState> _archiveDocument(DocumentRepository repository) {
} }
Middleware<AppState> _deleteDocument(DocumentRepository repository) { Middleware<AppState> _deleteDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteDocumentRequest;
final origDocument = store.state.documentState.map[action.documentId]; final origDocument = store.state.documentState.map[action.documentId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -118,7 +126,8 @@ Middleware<AppState> _deleteDocument(DocumentRepository repository) {
} }
Middleware<AppState> _restoreDocument(DocumentRepository repository) { Middleware<AppState> _restoreDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreDocumentRequest;
final origDocument = store.state.documentState.map[action.documentId]; final origDocument = store.state.documentState.map[action.documentId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -141,7 +150,8 @@ Middleware<AppState> _restoreDocument(DocumentRepository repository) {
} }
Middleware<AppState> _saveDocument(DocumentRepository repository) { Middleware<AppState> _saveDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveDocumentRequest;
if (store.state.selectedCompany.isEnterprisePlan) { if (store.state.selectedCompany.isEnterprisePlan) {
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -169,7 +179,8 @@ Middleware<AppState> _saveDocument(DocumentRepository repository) {
} }
Middleware<AppState> _loadDocument(DocumentRepository repository) { Middleware<AppState> _loadDocument(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadDocument;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -199,7 +210,8 @@ Middleware<AppState> _loadDocument(DocumentRepository repository) {
} }
Middleware<AppState> _loadDocuments(DocumentRepository repository) { Middleware<AppState> _loadDocuments(DocumentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadDocuments;
final AppState state = store.state; final AppState state = store.state;
if (!state.documentState.isStale && !action.force) { if (!state.documentState.isStale && !action.force) {

View File

@ -15,9 +15,9 @@ EntityUIState documentUIReducer(DocumentUIState state, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewDocument>( TypedReducer<int, ViewDocument>(
(int selectedId, dynamic action) => action.documentId), (selectedId, action) => action.documentId),
TypedReducer<int, AddDocumentSuccess>( TypedReducer<int, AddDocumentSuccess>(
(int selectedId, dynamic action) => action.document.id), (selectedId, action) => action.document.id),
]); ]);
final editingReducer = combineReducers<DocumentEntity>([ final editingReducer = combineReducers<DocumentEntity>([

View File

@ -39,7 +39,9 @@ List<Middleware<AppState>> createStoreExpensesMiddleware([
} }
Middleware<AppState> _editExpense() { Middleware<AppState> _editExpense() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditExpense;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route)); store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route));
@ -53,7 +55,9 @@ Middleware<AppState> _editExpense() {
} }
Middleware<AppState> _viewExpense() { Middleware<AppState> _viewExpense() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewExpense;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(ExpenseViewScreen.route)); store.dispatch(UpdateCurrentRoute(ExpenseViewScreen.route));
@ -62,7 +66,9 @@ Middleware<AppState> _viewExpense() {
} }
Middleware<AppState> _viewExpenseList() { Middleware<AppState> _viewExpenseList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewExpenseList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(ExpenseScreen.route)); store.dispatch(UpdateCurrentRoute(ExpenseScreen.route));
@ -73,7 +79,8 @@ Middleware<AppState> _viewExpenseList() {
} }
Middleware<AppState> _archiveExpense(ExpenseRepository repository) { Middleware<AppState> _archiveExpense(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveExpenseRequest;
final origExpense = store.state.expenseState.map[action.expenseId]; final origExpense = store.state.expenseState.map[action.expenseId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -96,7 +103,8 @@ Middleware<AppState> _archiveExpense(ExpenseRepository repository) {
} }
Middleware<AppState> _deleteExpense(ExpenseRepository repository) { Middleware<AppState> _deleteExpense(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteExpenseRequest;
final origExpense = store.state.expenseState.map[action.expenseId]; final origExpense = store.state.expenseState.map[action.expenseId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -119,7 +127,8 @@ Middleware<AppState> _deleteExpense(ExpenseRepository repository) {
} }
Middleware<AppState> _restoreExpense(ExpenseRepository repository) { Middleware<AppState> _restoreExpense(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreExpenseRequest;
final origExpense = store.state.expenseState.map[action.expenseId]; final origExpense = store.state.expenseState.map[action.expenseId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -142,7 +151,8 @@ Middleware<AppState> _restoreExpense(ExpenseRepository repository) {
} }
Middleware<AppState> _saveExpense(ExpenseRepository repository) { Middleware<AppState> _saveExpense(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveExpenseRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.expense) store.state.selectedCompany, store.state.authState, action.expense)
@ -164,7 +174,8 @@ Middleware<AppState> _saveExpense(ExpenseRepository repository) {
} }
Middleware<AppState> _loadExpense(ExpenseRepository repository) { Middleware<AppState> _loadExpense(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadExpense;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -194,7 +205,8 @@ Middleware<AppState> _loadExpense(ExpenseRepository repository) {
} }
Middleware<AppState> _loadExpenses(ExpenseRepository repository) { Middleware<AppState> _loadExpenses(ExpenseRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadExpenses;
final AppState state = store.state; final AppState state = store.state;
if (!state.expenseState.isStale && !action.force) { if (!state.expenseState.isStale && !action.force) {

View File

@ -15,9 +15,9 @@ EntityUIState expenseUIReducer(ExpenseUIState state, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewExpense>( TypedReducer<int, ViewExpense>(
(int selectedId, dynamic action) => action.expenseId), (selectedId, action) => action.expenseId),
TypedReducer<int, AddExpenseSuccess>( TypedReducer<int, AddExpenseSuccess>(
(int selectedId, dynamic action) => action.expense.id), (selectedId, action) => action.expense.id),
]); ]);
final editingReducer = combineReducers<ExpenseEntity>([ final editingReducer = combineReducers<ExpenseEntity>([

View File

@ -50,7 +50,9 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
} }
Middleware<AppState> _viewInvoiceList() { Middleware<AppState> _viewInvoiceList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewInvoiceList;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -67,7 +69,9 @@ Middleware<AppState> _viewInvoiceList() {
} }
Middleware<AppState> _viewInvoice() { Middleware<AppState> _viewInvoice() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewInvoice;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -83,7 +87,9 @@ Middleware<AppState> _viewInvoice() {
} }
Middleware<AppState> _editInvoice() { Middleware<AppState> _editInvoice() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditInvoice;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -104,7 +110,9 @@ Middleware<AppState> _editInvoice() {
} }
Middleware<AppState> _showEmailInvoice() { Middleware<AppState> _showEmailInvoice() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ShowEmailInvoice;
next(action); next(action);
final emailWasSent = final emailWasSent =
@ -117,7 +125,8 @@ Middleware<AppState> _showEmailInvoice() {
} }
Middleware<AppState> _archiveInvoice(InvoiceRepository repository) { Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveInvoiceRequest;
final origInvoice = store.state.invoiceState.map[action.invoiceId]; final origInvoice = store.state.invoiceState.map[action.invoiceId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -140,7 +149,8 @@ Middleware<AppState> _archiveInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _deleteInvoice(InvoiceRepository repository) { Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteInvoiceRequest;
final origInvoice = store.state.invoiceState.map[action.invoiceId]; final origInvoice = store.state.invoiceState.map[action.invoiceId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -164,7 +174,8 @@ Middleware<AppState> _deleteInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _restoreInvoice(InvoiceRepository repository) { Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreInvoiceRequest;
final origInvoice = store.state.invoiceState.map[action.invoiceId]; final origInvoice = store.state.invoiceState.map[action.invoiceId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -188,7 +199,8 @@ Middleware<AppState> _restoreInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _markSentInvoice(InvoiceRepository repository) { Middleware<AppState> _markSentInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as MarkSentInvoiceRequest;
final origInvoice = store.state.invoiceState.map[action.invoiceId]; final origInvoice = store.state.invoiceState.map[action.invoiceId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -212,7 +224,8 @@ Middleware<AppState> _markSentInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _emailInvoice(InvoiceRepository repository) { Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as EmailInvoiceRequest;
final origInvoice = store.state.invoiceState.map[action.invoiceId]; final origInvoice = store.state.invoiceState.map[action.invoiceId];
repository repository
.emailInvoice(store.state.selectedCompany, store.state.authState, .emailInvoice(store.state.selectedCompany, store.state.authState,
@ -236,7 +249,8 @@ Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _saveInvoice(InvoiceRepository repository) { Middleware<AppState> _saveInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveInvoiceRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.invoice) store.state.selectedCompany, store.state.authState, action.invoice)
@ -266,7 +280,8 @@ Middleware<AppState> _saveInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _loadInvoice(InvoiceRepository repository) { Middleware<AppState> _loadInvoice(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadInvoice;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -297,7 +312,8 @@ Middleware<AppState> _loadInvoice(InvoiceRepository repository) {
} }
Middleware<AppState> _loadInvoices(InvoiceRepository repository) { Middleware<AppState> _loadInvoices(InvoiceRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadInvoices;
final AppState state = store.state; final AppState state = store.state;
if (!state.invoiceState.isStale && !action.force) { if (!state.invoiceState.isStale && !action.force) {

View File

@ -36,11 +36,11 @@ String filterClientDropdownReducer(
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewInvoice>( TypedReducer<int, ViewInvoice>(
(int selectedId, dynamic action) => action.invoiceId), (selectedId, action) => action.invoiceId),
TypedReducer<int, AddInvoiceSuccess>( TypedReducer<int, AddInvoiceSuccess>(
(int selectedId, dynamic action) => action.invoice.id), (selectedId, action) => action.invoice.id),
TypedReducer<int, ShowEmailInvoice>( TypedReducer<int, ShowEmailInvoice>(
(int selectedId, dynamic action) => action.invoice.id), (selectedId, action) => action.invoice.id),
]); ]);
final editingReducer = combineReducers<InvoiceEntity>([ final editingReducer = combineReducers<InvoiceEntity>([

View File

@ -41,7 +41,10 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
} }
Middleware<AppState> _editPayment() { Middleware<AppState> _editPayment() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {
final action = dynamicAction as EditPayment;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(PaymentEditScreen.route)); store.dispatch(UpdateCurrentRoute(PaymentEditScreen.route));
@ -56,7 +59,8 @@ Middleware<AppState> _editPayment() {
} }
Middleware<AppState> _viewPayment() { Middleware<AppState> _viewPayment() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic action,
NextDispatcher next) async {
next(action); next(action);
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route)); store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
@ -65,7 +69,9 @@ Middleware<AppState> _viewPayment() {
} }
Middleware<AppState> _viewPaymentList() { Middleware<AppState> _viewPaymentList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewPaymentList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(PaymentScreen.route)); store.dispatch(UpdateCurrentRoute(PaymentScreen.route));
@ -76,7 +82,8 @@ Middleware<AppState> _viewPaymentList() {
} }
Middleware<AppState> _archivePayment(PaymentRepository repository) { Middleware<AppState> _archivePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchivePaymentRequest;
final origPayment = store.state.paymentState.map[action.paymentId]; final origPayment = store.state.paymentState.map[action.paymentId];
repository repository
.saveData( .saveData(
@ -100,7 +107,8 @@ Middleware<AppState> _archivePayment(PaymentRepository repository) {
} }
Middleware<AppState> _deletePayment(PaymentRepository repository) { Middleware<AppState> _deletePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeletePaymentRequest;
final origPayment = store.state.paymentState.map[action.paymentId]; final origPayment = store.state.paymentState.map[action.paymentId];
repository repository
.saveData( .saveData(
@ -125,7 +133,8 @@ Middleware<AppState> _deletePayment(PaymentRepository repository) {
} }
Middleware<AppState> _restorePayment(PaymentRepository repository) { Middleware<AppState> _restorePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestorePaymentRequest;
final origPayment = store.state.paymentState.map[action.paymentId]; final origPayment = store.state.paymentState.map[action.paymentId];
repository repository
.saveData( .saveData(
@ -150,7 +159,8 @@ Middleware<AppState> _restorePayment(PaymentRepository repository) {
} }
Middleware<AppState> _savePayment(PaymentRepository repository) { Middleware<AppState> _savePayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SavePaymentRequest;
final PaymentEntity payment = action.payment; final PaymentEntity payment = action.payment;
final bool sendEmail = final bool sendEmail =
payment.isNew ? store.state.uiState.emailPayment : false; payment.isNew ? store.state.uiState.emailPayment : false;
@ -177,7 +187,8 @@ Middleware<AppState> _savePayment(PaymentRepository repository) {
} }
Middleware<AppState> _emailPayment(PaymentRepository repository) { Middleware<AppState> _emailPayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as EmailPaymentRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.payment, store.state.selectedCompany, store.state.authState, action.payment,
@ -197,7 +208,7 @@ Middleware<AppState> _emailPayment(PaymentRepository repository) {
/* /*
Middleware<AppState> _loadPayment(PaymentRepository repository) { Middleware<AppState> _loadPayment(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -228,7 +239,8 @@ Middleware<AppState> _loadPayment(PaymentRepository repository) {
*/ */
Middleware<AppState> _loadPayments(PaymentRepository repository) { Middleware<AppState> _loadPayments(PaymentRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadPayments;
final AppState state = store.state; final AppState state = store.state;
if (!state.paymentState.isStale && !action.force) { if (!state.paymentState.isStale && !action.force) {

View File

@ -15,9 +15,9 @@ EntityUIState paymentUIReducer(PaymentUIState state, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewPayment>( TypedReducer<int, ViewPayment>(
(int selectedId, dynamic action) => action.paymentId), (selectedId, action) => action.paymentId),
TypedReducer<int, AddPaymentSuccess>( TypedReducer<int, AddPaymentSuccess>(
(int selectedId, dynamic action) => action.payment.id), (selectedId, action) => action.payment.id),
]); ]);
final editingReducer = combineReducers<PaymentEntity>([ final editingReducer = combineReducers<PaymentEntity>([

View File

@ -37,7 +37,9 @@ List<Middleware<AppState>> createStoreProductsMiddleware([
} }
Middleware<AppState> _editProduct() { Middleware<AppState> _editProduct() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditProduct;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -53,7 +55,9 @@ Middleware<AppState> _editProduct() {
} }
Middleware<AppState> _viewProduct() { Middleware<AppState> _viewProduct() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewProduct;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -69,7 +73,9 @@ Middleware<AppState> _viewProduct() {
} }
Middleware<AppState> _viewProductList() { Middleware<AppState> _viewProductList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewProductList;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }
@ -86,7 +92,8 @@ Middleware<AppState> _viewProductList() {
} }
Middleware<AppState> _archiveProduct(ProductRepository repository) { Middleware<AppState> _archiveProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveProductRequest;
final origProduct = store.state.productState.map[action.productId]; final origProduct = store.state.productState.map[action.productId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -109,7 +116,8 @@ Middleware<AppState> _archiveProduct(ProductRepository repository) {
} }
Middleware<AppState> _deleteProduct(ProductRepository repository) { Middleware<AppState> _deleteProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteProductRequest;
final origProduct = store.state.productState.map[action.productId]; final origProduct = store.state.productState.map[action.productId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -132,7 +140,8 @@ Middleware<AppState> _deleteProduct(ProductRepository repository) {
} }
Middleware<AppState> _restoreProduct(ProductRepository repository) { Middleware<AppState> _restoreProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreProductRequest;
final origProduct = store.state.productState.map[action.productId]; final origProduct = store.state.productState.map[action.productId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -155,7 +164,8 @@ Middleware<AppState> _restoreProduct(ProductRepository repository) {
} }
Middleware<AppState> _saveProduct(ProductRepository repository) { Middleware<AppState> _saveProduct(ProductRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveProductRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.product) store.state.selectedCompany, store.state.authState, action.product)
@ -177,7 +187,8 @@ Middleware<AppState> _saveProduct(ProductRepository repository) {
} }
Middleware<AppState> _loadProducts(ProductRepository repository) { Middleware<AppState> _loadProducts(ProductRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadProducts;
final AppState state = store.state; final AppState state = store.state;
if (!state.productState.isStale && !action.force) { if (!state.productState.isStale && !action.force) {

View File

@ -43,9 +43,9 @@ ProductEntity _updateEditing(ProductEntity client, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewProduct>( TypedReducer<int, ViewProduct>(
(int selectedId, dynamic action) => action.productId), (selectedId, action) => action.productId),
TypedReducer<int, AddProductSuccess>( TypedReducer<int, AddProductSuccess>(
(int selectedId, dynamic action) => action.product.id), (selectedId, action) => action.product.id),
]); ]);
final productListReducer = combineReducers<ListUIState>([ final productListReducer = combineReducers<ListUIState>([

View File

@ -39,7 +39,9 @@ List<Middleware<AppState>> createStoreProjectsMiddleware([
} }
Middleware<AppState> _editProject() { Middleware<AppState> _editProject() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditProject;
next(action); next(action);
if (action.trackRoute) { if (action.trackRoute) {
@ -56,7 +58,9 @@ Middleware<AppState> _editProject() {
} }
Middleware<AppState> _viewProject() { Middleware<AppState> _viewProject() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewProject;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(ProjectViewScreen.route)); store.dispatch(UpdateCurrentRoute(ProjectViewScreen.route));
@ -65,7 +69,9 @@ Middleware<AppState> _viewProject() {
} }
Middleware<AppState> _viewProjectList() { Middleware<AppState> _viewProjectList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewProjectList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(ProjectScreen.route)); store.dispatch(UpdateCurrentRoute(ProjectScreen.route));
@ -76,7 +82,8 @@ Middleware<AppState> _viewProjectList() {
} }
Middleware<AppState> _archiveProject(ProjectRepository repository) { Middleware<AppState> _archiveProject(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveProjectRequest;
final origProject = store.state.projectState.map[action.projectId]; final origProject = store.state.projectState.map[action.projectId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -99,7 +106,8 @@ Middleware<AppState> _archiveProject(ProjectRepository repository) {
} }
Middleware<AppState> _deleteProject(ProjectRepository repository) { Middleware<AppState> _deleteProject(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteProjectRequest;
final origProject = store.state.projectState.map[action.projectId]; final origProject = store.state.projectState.map[action.projectId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -122,7 +130,8 @@ Middleware<AppState> _deleteProject(ProjectRepository repository) {
} }
Middleware<AppState> _restoreProject(ProjectRepository repository) { Middleware<AppState> _restoreProject(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreProjectRequest;
final origProject = store.state.projectState.map[action.projectId]; final origProject = store.state.projectState.map[action.projectId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -145,7 +154,8 @@ Middleware<AppState> _restoreProject(ProjectRepository repository) {
} }
Middleware<AppState> _saveProject(ProjectRepository repository) { Middleware<AppState> _saveProject(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveProjectRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.project) store.state.selectedCompany, store.state.authState, action.project)
@ -167,7 +177,8 @@ Middleware<AppState> _saveProject(ProjectRepository repository) {
} }
Middleware<AppState> _loadProject(ProjectRepository repository) { Middleware<AppState> _loadProject(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadProject;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -200,7 +211,8 @@ Middleware<AppState> _loadProject(ProjectRepository repository) {
} }
Middleware<AppState> _loadProjects(ProjectRepository repository) { Middleware<AppState> _loadProjects(ProjectRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadProjects;
final AppState state = store.state; final AppState state = store.state;
if (!state.projectState.isStale && !action.force) { if (!state.projectState.isStale && !action.force) {

View File

@ -15,9 +15,9 @@ EntityUIState projectUIReducer(ProjectUIState state, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewProject>( TypedReducer<int, ViewProject>(
(int selectedId, dynamic action) => action.projectId), (selectedId, action) => action.projectId),
TypedReducer<int, AddProjectSuccess>( TypedReducer<int, AddProjectSuccess>(
(int selectedId, dynamic action) => action.project.id), (selectedId, action) => action.project.id),
]); ]);
final editingReducer = combineReducers<ProjectEntity>([ final editingReducer = combineReducers<ProjectEntity>([
@ -31,7 +31,7 @@ final editingReducer = combineReducers<ProjectEntity>([
TypedReducer<ProjectEntity, SelectCompany>(_clearEditing), TypedReducer<ProjectEntity, SelectCompany>(_clearEditing),
]); ]);
ProjectEntity _clearEditing(ProjectEntity project, dynamic action) { ProjectEntity _clearEditing(ProjectEntity project, dynamic dynamicAction) {
return ProjectEntity(); return ProjectEntity();
} }

View File

@ -46,7 +46,9 @@ List<Middleware<AppState>> createStoreQuotesMiddleware([
} }
Middleware<AppState> _viewQuote() { Middleware<AppState> _viewQuote() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewQuote;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route)); store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route));
@ -55,7 +57,9 @@ Middleware<AppState> _viewQuote() {
} }
Middleware<AppState> _viewQuoteList() { Middleware<AppState> _viewQuoteList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewQuoteList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(QuoteScreen.route)); store.dispatch(UpdateCurrentRoute(QuoteScreen.route));
@ -65,7 +69,9 @@ Middleware<AppState> _viewQuoteList() {
} }
Middleware<AppState> _editQuote() { Middleware<AppState> _editQuote() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditQuote;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route)); store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route));
@ -79,7 +85,9 @@ Middleware<AppState> _editQuote() {
} }
Middleware<AppState> _showEmailQuote() { Middleware<AppState> _showEmailQuote() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ShowEmailQuote;
next(action); next(action);
final emailWasSent = final emailWasSent =
@ -92,7 +100,8 @@ Middleware<AppState> _showEmailQuote() {
} }
Middleware<AppState> _archiveQuote(QuoteRepository repository) { Middleware<AppState> _archiveQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveQuoteRequest;
final origQuote = store.state.quoteState.map[action.quoteId]; final origQuote = store.state.quoteState.map[action.quoteId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origQuote, .saveData(store.state.selectedCompany, store.state.authState, origQuote,
@ -115,7 +124,8 @@ Middleware<AppState> _archiveQuote(QuoteRepository repository) {
} }
Middleware<AppState> _deleteQuote(QuoteRepository repository) { Middleware<AppState> _deleteQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteQuoteRequest;
final origQuote = store.state.quoteState.map[action.quoteId]; final origQuote = store.state.quoteState.map[action.quoteId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origQuote, .saveData(store.state.selectedCompany, store.state.authState, origQuote,
@ -138,7 +148,8 @@ Middleware<AppState> _deleteQuote(QuoteRepository repository) {
} }
Middleware<AppState> _restoreQuote(QuoteRepository repository) { Middleware<AppState> _restoreQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreQuoteRequest;
final origQuote = store.state.quoteState.map[action.quoteId]; final origQuote = store.state.quoteState.map[action.quoteId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origQuote, .saveData(store.state.selectedCompany, store.state.authState, origQuote,
@ -161,7 +172,8 @@ Middleware<AppState> _restoreQuote(QuoteRepository repository) {
} }
Middleware<AppState> _convertQuote(QuoteRepository repository) { Middleware<AppState> _convertQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ConvertQuote;
final quote = store.state.quoteState.map[action.quoteId]; final quote = store.state.quoteState.map[action.quoteId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, quote, .saveData(store.state.selectedCompany, store.state.authState, quote,
@ -180,7 +192,8 @@ Middleware<AppState> _convertQuote(QuoteRepository repository) {
} }
Middleware<AppState> _markSentQuote(QuoteRepository repository) { Middleware<AppState> _markSentQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as MarkSentQuoteRequest;
final origQuote = store.state.quoteState.map[action.quoteId]; final origQuote = store.state.quoteState.map[action.quoteId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origQuote, .saveData(store.state.selectedCompany, store.state.authState, origQuote,
@ -203,7 +216,8 @@ Middleware<AppState> _markSentQuote(QuoteRepository repository) {
} }
Middleware<AppState> _emailQuote(QuoteRepository repository) { Middleware<AppState> _emailQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as EmailQuoteRequest;
final origQuote = store.state.quoteState.map[action.quoteId]; final origQuote = store.state.quoteState.map[action.quoteId];
repository repository
.emailQuote(store.state.selectedCompany, store.state.authState, .emailQuote(store.state.selectedCompany, store.state.authState,
@ -226,7 +240,8 @@ Middleware<AppState> _emailQuote(QuoteRepository repository) {
} }
Middleware<AppState> _saveQuote(QuoteRepository repository) { Middleware<AppState> _saveQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveQuoteRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.quote) store.state.selectedCompany, store.state.authState, action.quote)
@ -248,7 +263,8 @@ Middleware<AppState> _saveQuote(QuoteRepository repository) {
} }
Middleware<AppState> _loadQuote(QuoteRepository repository) { Middleware<AppState> _loadQuote(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadQuote;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -281,7 +297,8 @@ Middleware<AppState> _loadQuote(QuoteRepository repository) {
} }
Middleware<AppState> _loadQuotes(QuoteRepository repository) { Middleware<AppState> _loadQuotes(QuoteRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadQuotes;
final AppState state = store.state; final AppState state = store.state;
if (!state.quoteState.isStale && !action.force) { if (!state.quoteState.isStale && !action.force) {

View File

@ -35,11 +35,11 @@ String filterClientDropdownReducer(
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewQuote>( TypedReducer<int, ViewQuote>(
(int selectedId, dynamic action) => action.quoteId), (selectedId, action) => action.quoteId),
TypedReducer<int, AddQuoteSuccess>( TypedReducer<int, AddQuoteSuccess>(
(int selectedId, dynamic action) => action.quote.id), (selectedId, action) => action.quote.id),
TypedReducer<int, ShowEmailQuote>( TypedReducer<int, ShowEmailQuote>(
(int selectedId, dynamic action) => action.quote.id), (selectedId, action) => action.quote.id),
]); ]);
final editingReducer = combineReducers<InvoiceEntity>([ final editingReducer = combineReducers<InvoiceEntity>([

View File

@ -16,7 +16,9 @@ List<Middleware<AppState>> createStoreSettingsMiddleware() {
} }
Middleware<AppState> _viewSettings() { Middleware<AppState> _viewSettings() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewSettings;
if (hasChanges(store, action)) { if (hasChanges(store, action)) {
return; return;
} }

View File

@ -38,7 +38,9 @@ List<Middleware<AppState>> createStoreTasksMiddleware([
} }
Middleware<AppState> _editTask() { Middleware<AppState> _editTask() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as EditTask;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(TaskEditScreen.route)); store.dispatch(UpdateCurrentRoute(TaskEditScreen.route));
@ -52,7 +54,9 @@ Middleware<AppState> _editTask() {
} }
Middleware<AppState> _viewTask() { Middleware<AppState> _viewTask() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
final action = dynamicAction as ViewTask;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(TaskViewScreen.route)); store.dispatch(UpdateCurrentRoute(TaskViewScreen.route));
@ -61,7 +65,9 @@ Middleware<AppState> _viewTask() {
} }
Middleware<AppState> _viewTaskList() { Middleware<AppState> _viewTaskList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewTaskList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(TaskScreen.route)); store.dispatch(UpdateCurrentRoute(TaskScreen.route));
@ -72,7 +78,8 @@ Middleware<AppState> _viewTaskList() {
} }
Middleware<AppState> _archiveTask(TaskRepository repository) { Middleware<AppState> _archiveTask(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveTaskRequest;
final origTask = store.state.taskState.map[action.taskId]; final origTask = store.state.taskState.map[action.taskId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origTask, .saveData(store.state.selectedCompany, store.state.authState, origTask,
@ -95,7 +102,8 @@ Middleware<AppState> _archiveTask(TaskRepository repository) {
} }
Middleware<AppState> _deleteTask(TaskRepository repository) { Middleware<AppState> _deleteTask(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteTaskRequest;
final origTask = store.state.taskState.map[action.taskId]; final origTask = store.state.taskState.map[action.taskId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origTask, .saveData(store.state.selectedCompany, store.state.authState, origTask,
@ -118,7 +126,8 @@ Middleware<AppState> _deleteTask(TaskRepository repository) {
} }
Middleware<AppState> _restoreTask(TaskRepository repository) { Middleware<AppState> _restoreTask(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreTaskRequest;
final origTask = store.state.taskState.map[action.taskId]; final origTask = store.state.taskState.map[action.taskId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, origTask, .saveData(store.state.selectedCompany, store.state.authState, origTask,
@ -141,7 +150,8 @@ Middleware<AppState> _restoreTask(TaskRepository repository) {
} }
Middleware<AppState> _saveTask(TaskRepository repository) { Middleware<AppState> _saveTask(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveTaskRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.task) store.state.selectedCompany, store.state.authState, action.task)
@ -163,7 +173,8 @@ Middleware<AppState> _saveTask(TaskRepository repository) {
} }
Middleware<AppState> _loadTask(TaskRepository repository) { Middleware<AppState> _loadTask(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadTask;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -193,7 +204,8 @@ Middleware<AppState> _loadTask(TaskRepository repository) {
} }
Middleware<AppState> _loadTasks(TaskRepository repository) { Middleware<AppState> _loadTasks(TaskRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadTasks;
final AppState state = store.state; final AppState state = store.state;
if (!state.taskState.isStale && !action.force) { if (!state.taskState.isStale && !action.force) {

View File

@ -25,9 +25,9 @@ TaskTime editTaskTime(TaskTime taskTime, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewTask>( TypedReducer<int, ViewTask>(
(int selectedId, dynamic action) => action.taskId), (selectedId, action) => action.taskId),
TypedReducer<int, AddTaskSuccess>( TypedReducer<int, AddTaskSuccess>(
(int selectedId, dynamic action) => action.task.id), (selectedId, action) => action.task.id),
]); ]);
final editingReducer = combineReducers<TaskEntity>([ final editingReducer = combineReducers<TaskEntity>([

View File

@ -39,7 +39,10 @@ List<Middleware<AppState>> createStoreVendorsMiddleware([
} }
Middleware<AppState> _editVendor() { Middleware<AppState> _editVendor() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {
final action = dynamicAction as EditVendor;
next(action); next(action);
if (action.trackRoute) { if (action.trackRoute) {
@ -56,7 +59,10 @@ Middleware<AppState> _editVendor() {
} }
Middleware<AppState> _viewVendor() { Middleware<AppState> _viewVendor() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction,
NextDispatcher next) async {
final action = dynamicAction as ViewVendor;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(VendorViewScreen.route)); store.dispatch(UpdateCurrentRoute(VendorViewScreen.route));
@ -65,7 +71,9 @@ Middleware<AppState> _viewVendor() {
} }
Middleware<AppState> _viewVendorList() { Middleware<AppState> _viewVendorList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ViewVendorList;
next(action); next(action);
store.dispatch(UpdateCurrentRoute(VendorScreen.route)); store.dispatch(UpdateCurrentRoute(VendorScreen.route));
@ -76,7 +84,8 @@ Middleware<AppState> _viewVendorList() {
} }
Middleware<AppState> _archiveVendor(VendorRepository repository) { Middleware<AppState> _archiveVendor(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as ArchiveVendorRequest;
final origVendor = store.state.vendorState.map[action.vendorId]; final origVendor = store.state.vendorState.map[action.vendorId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -99,7 +108,8 @@ Middleware<AppState> _archiveVendor(VendorRepository repository) {
} }
Middleware<AppState> _deleteVendor(VendorRepository repository) { Middleware<AppState> _deleteVendor(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as DeleteVendorRequest;
final origVendor = store.state.vendorState.map[action.vendorId]; final origVendor = store.state.vendorState.map[action.vendorId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -122,7 +132,8 @@ Middleware<AppState> _deleteVendor(VendorRepository repository) {
} }
Middleware<AppState> _restoreVendor(VendorRepository repository) { Middleware<AppState> _restoreVendor(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as RestoreVendorRequest;
final origVendor = store.state.vendorState.map[action.vendorId]; final origVendor = store.state.vendorState.map[action.vendorId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -145,7 +156,8 @@ Middleware<AppState> _restoreVendor(VendorRepository repository) {
} }
Middleware<AppState> _saveVendor(VendorRepository repository) { Middleware<AppState> _saveVendor(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as SaveVendorRequest;
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.vendor) store.state.selectedCompany, store.state.authState, action.vendor)
@ -167,7 +179,8 @@ Middleware<AppState> _saveVendor(VendorRepository repository) {
} }
Middleware<AppState> _loadVendor(VendorRepository repository) { Middleware<AppState> _loadVendor(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadVendor;
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -203,7 +216,8 @@ Middleware<AppState> _loadVendor(VendorRepository repository) {
} }
Middleware<AppState> _loadVendors(VendorRepository repository) { Middleware<AppState> _loadVendors(VendorRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final action = dynamicAction as LoadVendors;
final AppState state = store.state; final AppState state = store.state;
if (!state.vendorState.isStale && !action.force) { if (!state.vendorState.isStale && !action.force) {

View File

@ -27,9 +27,9 @@ VendorContactEntity editVendorContact(
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewVendor>( TypedReducer<int, ViewVendor>(
(int selectedId, dynamic action) => action.vendorId), (selectedId, action) => action.vendorId),
TypedReducer<int, AddVendorSuccess>( TypedReducer<int, AddVendorSuccess>(
(int selectedId, dynamic action) => action.vendor.id), (selectedId, action) => action.vendor.id),
]); ]);
final editingReducer = combineReducers<VendorEntity>([ final editingReducer = combineReducers<VendorEntity>([

View File

@ -37,7 +37,7 @@ List<Middleware<AppState>> createStoreStubsMiddleware([
} }
Middleware<AppState> _editStub() { Middleware<AppState> _editStub() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
next(action); next(action);
store.dispatch(UpdateCurrentRoute(StubEditScreen.route)); store.dispatch(UpdateCurrentRoute(StubEditScreen.route));
@ -51,7 +51,7 @@ Middleware<AppState> _editStub() {
} }
Middleware<AppState> _viewStub() { Middleware<AppState> _viewStub() {
return (Store<AppState> store, dynamic action, NextDispatcher next) async { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
next(action); next(action);
store.dispatch(UpdateCurrentRoute(StubViewScreen.route)); store.dispatch(UpdateCurrentRoute(StubViewScreen.route));
@ -60,7 +60,7 @@ Middleware<AppState> _viewStub() {
} }
Middleware<AppState> _viewStubList() { Middleware<AppState> _viewStubList() {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
next(action); next(action);
store.dispatch(UpdateCurrentRoute(StubScreen.route)); store.dispatch(UpdateCurrentRoute(StubScreen.route));
@ -70,7 +70,7 @@ Middleware<AppState> _viewStubList() {
} }
Middleware<AppState> _archiveStub(StubRepository repository) { Middleware<AppState> _archiveStub(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final origStub = store.state.stubState.map[action.stubId]; final origStub = store.state.stubState.map[action.stubId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -93,7 +93,7 @@ Middleware<AppState> _archiveStub(StubRepository repository) {
} }
Middleware<AppState> _deleteStub(StubRepository repository) { Middleware<AppState> _deleteStub(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final origStub = store.state.stubState.map[action.stubId]; final origStub = store.state.stubState.map[action.stubId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -116,7 +116,7 @@ Middleware<AppState> _deleteStub(StubRepository repository) {
} }
Middleware<AppState> _restoreStub(StubRepository repository) { Middleware<AppState> _restoreStub(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final origStub = store.state.stubState.map[action.stubId]; final origStub = store.state.stubState.map[action.stubId];
repository repository
.saveData(store.state.selectedCompany, store.state.authState, .saveData(store.state.selectedCompany, store.state.authState,
@ -139,7 +139,7 @@ Middleware<AppState> _restoreStub(StubRepository repository) {
} }
Middleware<AppState> _saveStub(StubRepository repository) { Middleware<AppState> _saveStub(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
repository repository
.saveData( .saveData(
store.state.selectedCompany, store.state.authState, action.stub) store.state.selectedCompany, store.state.authState, action.stub)
@ -161,7 +161,7 @@ Middleware<AppState> _saveStub(StubRepository repository) {
} }
Middleware<AppState> _loadStub(StubRepository repository) { Middleware<AppState> _loadStub(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final AppState state = store.state; final AppState state = store.state;
if (state.isLoading) { if (state.isLoading) {
@ -191,7 +191,7 @@ Middleware<AppState> _loadStub(StubRepository repository) {
} }
Middleware<AppState> _loadStubs(StubRepository repository) { Middleware<AppState> _loadStubs(StubRepository repository) {
return (Store<AppState> store, dynamic action, NextDispatcher next) { return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
final AppState state = store.state; final AppState state = store.state;
if (!state.stubState.isStale && !action.force) { if (!state.stubState.isStale && !action.force) {

View File

@ -6,7 +6,7 @@ import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart';
import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart'; import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart';
import 'package:invoiceninja_flutter/redux/stub/stub_state.dart'; import 'package:invoiceninja_flutter/redux/stub/stub_state.dart';
EntityUIState stubUIReducer(StubUIState state, dynamic action) { EntityUIState stubUIReducer(StubUIState state, dynamic dynamicAction) {
return state.rebuild((b) => b return state.rebuild((b) => b
..listUIState.replace(stubListReducer(state.listUIState, action)) ..listUIState.replace(stubListReducer(state.listUIState, action))
..editing.replace(editingReducer(state.editing, action)) ..editing.replace(editingReducer(state.editing, action))
@ -15,9 +15,9 @@ EntityUIState stubUIReducer(StubUIState state, dynamic action) {
Reducer<int> selectedIdReducer = combineReducers([ Reducer<int> selectedIdReducer = combineReducers([
TypedReducer<int, ViewStub>( TypedReducer<int, ViewStub>(
(int selectedId, dynamic action) => action.stubId), (int selectedId, dynamic dynamicAction) => action.stubId),
TypedReducer<int, AddStubSuccess>( TypedReducer<int, AddStubSuccess>(
(int selectedId, dynamic action) => action.stub.id), (int selectedId, dynamic dynamicAction) => action.stub.id),
]); ]);
final editingReducer = combineReducers<StubEntity>([ final editingReducer = combineReducers<StubEntity>([
@ -31,11 +31,11 @@ final editingReducer = combineReducers<StubEntity>([
TypedReducer<StubEntity, SelectCompany>(_clearEditing), TypedReducer<StubEntity, SelectCompany>(_clearEditing),
]); ]);
StubEntity _clearEditing(StubEntity stub, dynamic action) { StubEntity _clearEditing(StubEntity stub, dynamic dynamicAction) {
return StubEntity(); return StubEntity();
} }
StubEntity _updateEditing(StubEntity stub, dynamic action) { StubEntity _updateEditing(StubEntity stub, dynamic dynamicAction) {
return action.stub; return action.stub;
} }