Improve documents
This commit is contained in:
parent
a9288f19b7
commit
e58815d8cd
|
|
@ -169,12 +169,13 @@ Middleware<AppState> _downloadDocuments(DocumentRepository repository) {
|
|||
Middleware<AppState> _deleteDocument(DocumentRepository repository) {
|
||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||
final action = dynamicAction as DeleteDocumentRequest;
|
||||
final documentId = action.documentIds.first;
|
||||
|
||||
repository
|
||||
.delete(store.state.credentials, action.documentIds.first,
|
||||
action.password, action.idToken)
|
||||
.delete(store.state.credentials, documentId, action.password,
|
||||
action.idToken)
|
||||
.then((value) {
|
||||
store.dispatch(DeleteDocumentSuccess());
|
||||
store.dispatch(DeleteDocumentSuccess(documentId: documentId));
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,9 @@ DocumentState _archiveDocumentSuccess(
|
|||
|
||||
DocumentState _deleteDocumentSuccess(
|
||||
DocumentState documentState, DeleteDocumentSuccess action) {
|
||||
return documentState.rebuild((b) => b..map.remove(action.documentId));
|
||||
return documentState.rebuild((b) => b
|
||||
..map.remove(action.documentId)
|
||||
..list.remove(action.documentId));
|
||||
}
|
||||
|
||||
DocumentState _restoreDocumentSuccess(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Package imports:
|
||||
import 'package:invoiceninja_flutter/redux/document/document_actions.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_state.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
|
|
@ -78,6 +79,11 @@ Reducer<SettingsUIState> settingsUIReducer = combineReducers([
|
|||
..updatedAt = DateTime.now().millisecondsSinceEpoch
|
||||
..isChanged = false);
|
||||
}),
|
||||
TypedReducer<SettingsUIState, DeleteDocumentSuccess>((state, action) {
|
||||
return state.rebuild(
|
||||
(b) => b..updatedAt = DateTime.now().millisecondsSinceEpoch,
|
||||
);
|
||||
}),
|
||||
TypedReducer<SettingsUIState, SaveGroupSuccess>((state, action) {
|
||||
return state.rebuild((b) => b
|
||||
..group.replace(action.group)
|
||||
|
|
|
|||
|
|
@ -251,9 +251,9 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
),
|
||||
if (!state.settingsUIState.isFiltered)
|
||||
Tab(
|
||||
text: company.documents.isEmpty
|
||||
text: state.company.documents.isEmpty
|
||||
? localization.documents
|
||||
: '${localization.documents} (${company.documents.length})',
|
||||
: '${localization.documents} (${state.company.documents.length})',
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
@ -700,7 +700,7 @@ class _CompanyDetailsState extends State<CompanyDetails>
|
|||
),
|
||||
if (!state.settingsUIState.isFiltered)
|
||||
DocumentGrid(
|
||||
documents: company.documents.toList(),
|
||||
documents: state.company.documents.toList(),
|
||||
onUploadDocument: (path) =>
|
||||
viewModel.onUploadDocuments(context, path),
|
||||
onDeleteDocument: (document, password, idToken) => viewModel
|
||||
|
|
|
|||
Loading…
Reference in New Issue