More work on inbox, refactorings (bloc separation of concerns), fixed saved views wrong sort order

This commit is contained in:
Anton Stubenbord
2022-11-29 01:09:36 +01:00
parent 5edbdabf26
commit 50190f035e
43 changed files with 605 additions and 463 deletions

View File

@@ -15,11 +15,6 @@ class DocumentsCubit extends Cubit<DocumentsState> {
DocumentsCubit(this.documentRepository) : super(DocumentsState.initial);
Future<void> remove(DocumentModel document) async {
await documentRepository.delete(document);
await reload();
}
Future<void> bulkRemove(List<DocumentModel> documents) async {
await documentRepository.bulkAction(
BulkDeleteAction(documents.map((doc) => doc.id)),
@@ -40,8 +35,13 @@ class DocumentsCubit extends Cubit<DocumentsState> {
await reload();
}
Future<void> update(DocumentModel document) async {
await documentRepository.update(document);
Future<void> update(
DocumentModel document, [
bool updateRemote = true,
]) async {
if (updateRemote) {
await documentRepository.update(document);
}
await reload();
}
@@ -83,13 +83,6 @@ class DocumentsCubit extends Cubit<DocumentsState> {
isLoaded: true, value: [...state.value, result], filter: newFilter));
}
Future<void> assignAsn(DocumentModel document) async {
if (document.archiveSerialNumber == null) {
final int asn = await documentRepository.findNextAsn();
update(document.copyWith(archiveSerialNumber: asn));
}
}
///
/// Update filter state and automatically reload documents. Always resets page to 1.
/// Use [DocumentsCubit.loadMore] to load more data.