mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 04:07:51 -06:00
feat: Add hive type adapters to api models, migrate to freezed
This commit is contained in:
@@ -13,8 +13,7 @@ import 'package:paperless_mobile/features/paged_document_view/cubit/document_pag
|
||||
part 'inbox_cubit.g.dart';
|
||||
part 'inbox_state.dart';
|
||||
|
||||
class InboxCubit extends HydratedCubit<InboxState>
|
||||
with DocumentPagingBlocMixin {
|
||||
class InboxCubit extends HydratedCubit<InboxState> with DocumentPagingBlocMixin {
|
||||
final LabelRepository _labelRepository;
|
||||
|
||||
final PaperlessDocumentsApi _documentsApi;
|
||||
@@ -39,10 +38,7 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
this,
|
||||
onDeleted: remove,
|
||||
onUpdated: (document) {
|
||||
if (document.tags
|
||||
.toSet()
|
||||
.intersection(state.inboxTags.toSet())
|
||||
.isEmpty) {
|
||||
if (document.tags.toSet().intersection(state.inboxTags.toSet()).isEmpty) {
|
||||
remove(document);
|
||||
emit(state.copyWith(itemsInInboxCount: state.itemsInInboxCount - 1));
|
||||
} else {
|
||||
@@ -101,7 +97,7 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
updateFilter(
|
||||
filter: DocumentFilter(
|
||||
sortField: SortField.added,
|
||||
tags: IdsTagsQuery.fromIds(inboxTags),
|
||||
tags: TagsQuery.ids(include: inboxTags),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -131,7 +127,7 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
updateFilter(
|
||||
filter: DocumentFilter(
|
||||
sortField: SortField.added,
|
||||
tags: IdsTagsQuery.fromIds(inboxTags),
|
||||
tags: TagsQuery.ids(include: inboxTags),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -141,8 +137,7 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
/// from the inbox.
|
||||
///
|
||||
Future<Iterable<int>> removeFromInbox(DocumentModel document) async {
|
||||
final tagsToRemove =
|
||||
document.tags.toSet().intersection(state.inboxTags.toSet());
|
||||
final tagsToRemove = document.tags.toSet().intersection(state.inboxTags.toSet());
|
||||
|
||||
final updatedTags = {...document.tags}..removeAll(tagsToRemove);
|
||||
final updatedDocument = await api.update(
|
||||
@@ -196,8 +191,8 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
Future<void> assignAsn(DocumentModel document) async {
|
||||
if (document.archiveSerialNumber == null) {
|
||||
final int asn = await _documentsApi.findNextAsn();
|
||||
final updatedDocument = await _documentsApi
|
||||
.update(document.copyWith(archiveSerialNumber: () => asn));
|
||||
final updatedDocument =
|
||||
await _documentsApi.update(document.copyWith(archiveSerialNumber: () => asn));
|
||||
|
||||
replace(updatedDocument);
|
||||
}
|
||||
@@ -222,4 +217,7 @@ class InboxCubit extends HydratedCubit<InboxState>
|
||||
_labelRepository.removeListener(this);
|
||||
return super.close();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onFilterUpdated(DocumentFilter filter) async {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user