mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-10 14:07:59 -06:00
Removed suggestions from inbox, added translations, added paging to inbox, visual updates, changed default matching algorithm to auto
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user