Add use case to list archived files

This commit is contained in:
Ming Ming 2024-05-04 20:07:27 +08:00
parent 7b98a282ed
commit 692ccd2e9e
5 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,13 @@
import 'package:nc_photos/account.dart';
import 'package:nc_photos/di_container.dart';
import 'package:nc_photos/entity/file_descriptor.dart';
class ListArchivedFile {
const ListArchivedFile(this._c);
/// Return list of archived files
Future<List<FileDescriptor>> call(Account account, String shareDirPath) =>
_c.fileRepo2.getFileDescriptors(account, shareDirPath, isArchived: true);
final DiContainer _c;
}

View file

@ -346,6 +346,7 @@ abstract class NpDb {
List<String>? relativePathKeywords,
String? location,
bool? isFavorite,
bool? isArchived,
List<String>? mimes,
TimeRange? timeRange,
int? offset,

View file

@ -401,6 +401,7 @@ extension SqliteDbFileExtension on SqliteDb {
List<String>? relativePathKeywords,
String? location,
bool? isFavorite,
bool? isArchived,
List<String>? mimes,
TimeRange? timeRange,
int? offset,
@ -415,6 +416,7 @@ extension SqliteDbFileExtension on SqliteDb {
"relativePathKeywords: $relativePathKeywords, "
"location: $location, "
"isFavorite: $isFavorite, "
"isArchived: $isArchived, "
"mimes: $mimes, "
"timeRange: $timeRange, "
"offset: $offset, "
@ -477,6 +479,9 @@ extension SqliteDbFileExtension on SqliteDb {
if (isFavorite != null) {
q.byFavorite(isFavorite);
}
if (isArchived != null) {
q.byArchived(isArchived);
}
return q.build();
});
if (excludeRelativeRoots != null) {

View file

@ -87,6 +87,10 @@ class FilesQueryBuilder {
_byFavorite = favorite;
}
void byArchived(bool archived) {
_byArchived = archived;
}
void byDirRowId(int dirRowId) {
_byDirRowId = dirRowId;
}
@ -188,6 +192,15 @@ class FilesQueryBuilder {
db.accountFiles.isFavorite.isNull());
}
}
if (_byArchived != null) {
if (_byArchived!) {
query.where(db.accountFiles.isArchived.equals(true));
} else {
// null are treated as false
query.where(db.accountFiles.isArchived.equals(false) |
db.accountFiles.isArchived.isNull());
}
}
if (_byDirRowId != null) {
query.where(db.dirFiles.dir.equals(_byDirRowId!));
}
@ -232,6 +245,7 @@ class FilesQueryBuilder {
List<int>? _byOrDirRowIds;
List<String>? _byMimePatterns;
bool? _byFavorite;
bool? _byArchived;
int? _byDirRowId;
int? _byServerRowId;
String? _byLocation;

View file

@ -443,6 +443,7 @@ class NpDbSqlite implements NpDb {
List<String>? relativePathKeywords,
String? location,
bool? isFavorite,
bool? isArchived,
List<String>? mimes,
TimeRange? timeRange,
int? offset,
@ -458,6 +459,7 @@ class NpDbSqlite implements NpDb {
relativePathKeywords: relativePathKeywords,
location: location,
isFavorite: isFavorite,
isArchived: isArchived,
mimes: mimes,
timeRange: timeRange,
offset: offset,