Removed suggestions from inbox, added translations, added paging to inbox, visual updates, changed default matching algorithm to auto

This commit is contained in:
Anton Stubenbord
2023-01-20 00:34:18 +01:00
parent bfbf0a6f0e
commit f9dfddf704
56 changed files with 1748 additions and 766 deletions

View File

@@ -0,0 +1,70 @@
import 'package:equatable/equatable.dart';
import 'package:paperless_api/paperless_api.dart';
abstract class DocumentsPagedState extends Equatable {
final bool hasLoaded;
final bool isLoading;
final List<PagedSearchResult<DocumentModel>> value;
final DocumentFilter filter;
const DocumentsPagedState({
this.value = const [],
this.hasLoaded = false,
this.isLoading = false,
this.filter = const DocumentFilter(),
});
List<DocumentModel> get documents {
return value.fold(
[],
(previousValue, element) => [
...previousValue,
...element.results,
],
);
}
int get currentPageNumber {
assert(value.isNotEmpty);
return value.last.pageKey;
}
int? get nextPageNumber {
return isLastPageLoaded ? null : currentPageNumber + 1;
}
int get count {
if (value.isEmpty) {
return 0;
}
return value.first.count;
}
bool get isLastPageLoaded {
if (!hasLoaded) {
return false;
}
if (value.isNotEmpty) {
return value.last.next == null;
}
return true;
}
int inferPageCount({required int pageSize}) {
if (!hasLoaded) {
return 100000;
}
if (value.isEmpty) {
return 0;
}
return value.first.inferPageCount(pageSize: pageSize);
}
// Return type has to be dynamic
dynamic copyWithPaged({
bool? hasLoaded,
bool? isLoading,
List<PagedSearchResult<DocumentModel>>? value,
DocumentFilter? filter,
});
}