Improve doc

This commit is contained in:
Ming Ming 2024-02-13 19:24:16 +08:00
parent 91caf39184
commit 64b281289b
2 changed files with 11 additions and 1 deletions

View file

@ -10,6 +10,8 @@ part 'repo.g.dart';
abstract class FileRepo2 { abstract class FileRepo2 {
/// Query all files belonging to [account] /// Query all files belonging to [account]
/// ///
/// Returned files are sorted by time in descending order
///
/// Normally the stream should complete with only a single event, but some /// Normally the stream should complete with only a single event, but some
/// implementation might want to return multiple set of values, say one set of /// implementation might want to return multiple set of values, say one set of
/// cached value and later another set of updated value from a remote source. /// cached value and later another set of updated value from a remote source.
@ -127,6 +129,8 @@ class CachedFileRepo implements FileRepo2 {
abstract class FileDataSource2 { abstract class FileDataSource2 {
/// Query all files belonging to [account] /// Query all files belonging to [account]
///
/// Returned files are sorted by time in descending order
Stream<List<FileDescriptor>> getFileDescriptors( Stream<List<FileDescriptor>> getFileDescriptors(
Account account, String shareDirPath); Account account, String shareDirPath);

View file

@ -501,18 +501,24 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
); );
} }
/// Remove file items not recognized by the app
List<CollectionItem> _filterItems( List<CollectionItem> _filterItems(
List<CollectionItem> rawItems, Set<int>? whitelist) { List<CollectionItem> rawItems, Set<int>? whitelist) {
if (whitelist == null) { if (whitelist == null) {
return rawItems; return rawItems;
} }
return rawItems.where((e) { final results = rawItems.where((e) {
if (e is CollectionFileItem) { if (e is CollectionFileItem) {
return whitelist.contains(e.file.fdId); return whitelist.contains(e.file.fdId);
} else { } else {
return true; return true;
} }
}).toList(); }).toList();
if (rawItems.length != results.length) {
_log.fine(
"[_filterItems] ${rawItems.length - results.length} items filtered out");
}
return results;
} }
String? _getCoverUrlByItems() { String? _getCoverUrlByItems() {