mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Add use case to list archived files
This commit is contained in:
parent
7b98a282ed
commit
692ccd2e9e
5 changed files with 35 additions and 0 deletions
13
app/lib/use_case/list_archived_file.dart
Normal file
13
app/lib/use_case/list_archived_file.dart
Normal 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;
|
||||||
|
}
|
|
@ -346,6 +346,7 @@ abstract class NpDb {
|
||||||
List<String>? relativePathKeywords,
|
List<String>? relativePathKeywords,
|
||||||
String? location,
|
String? location,
|
||||||
bool? isFavorite,
|
bool? isFavorite,
|
||||||
|
bool? isArchived,
|
||||||
List<String>? mimes,
|
List<String>? mimes,
|
||||||
TimeRange? timeRange,
|
TimeRange? timeRange,
|
||||||
int? offset,
|
int? offset,
|
||||||
|
|
|
@ -401,6 +401,7 @@ extension SqliteDbFileExtension on SqliteDb {
|
||||||
List<String>? relativePathKeywords,
|
List<String>? relativePathKeywords,
|
||||||
String? location,
|
String? location,
|
||||||
bool? isFavorite,
|
bool? isFavorite,
|
||||||
|
bool? isArchived,
|
||||||
List<String>? mimes,
|
List<String>? mimes,
|
||||||
TimeRange? timeRange,
|
TimeRange? timeRange,
|
||||||
int? offset,
|
int? offset,
|
||||||
|
@ -415,6 +416,7 @@ extension SqliteDbFileExtension on SqliteDb {
|
||||||
"relativePathKeywords: $relativePathKeywords, "
|
"relativePathKeywords: $relativePathKeywords, "
|
||||||
"location: $location, "
|
"location: $location, "
|
||||||
"isFavorite: $isFavorite, "
|
"isFavorite: $isFavorite, "
|
||||||
|
"isArchived: $isArchived, "
|
||||||
"mimes: $mimes, "
|
"mimes: $mimes, "
|
||||||
"timeRange: $timeRange, "
|
"timeRange: $timeRange, "
|
||||||
"offset: $offset, "
|
"offset: $offset, "
|
||||||
|
@ -477,6 +479,9 @@ extension SqliteDbFileExtension on SqliteDb {
|
||||||
if (isFavorite != null) {
|
if (isFavorite != null) {
|
||||||
q.byFavorite(isFavorite);
|
q.byFavorite(isFavorite);
|
||||||
}
|
}
|
||||||
|
if (isArchived != null) {
|
||||||
|
q.byArchived(isArchived);
|
||||||
|
}
|
||||||
return q.build();
|
return q.build();
|
||||||
});
|
});
|
||||||
if (excludeRelativeRoots != null) {
|
if (excludeRelativeRoots != null) {
|
||||||
|
|
|
@ -87,6 +87,10 @@ class FilesQueryBuilder {
|
||||||
_byFavorite = favorite;
|
_byFavorite = favorite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void byArchived(bool archived) {
|
||||||
|
_byArchived = archived;
|
||||||
|
}
|
||||||
|
|
||||||
void byDirRowId(int dirRowId) {
|
void byDirRowId(int dirRowId) {
|
||||||
_byDirRowId = dirRowId;
|
_byDirRowId = dirRowId;
|
||||||
}
|
}
|
||||||
|
@ -188,6 +192,15 @@ class FilesQueryBuilder {
|
||||||
db.accountFiles.isFavorite.isNull());
|
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) {
|
if (_byDirRowId != null) {
|
||||||
query.where(db.dirFiles.dir.equals(_byDirRowId!));
|
query.where(db.dirFiles.dir.equals(_byDirRowId!));
|
||||||
}
|
}
|
||||||
|
@ -232,6 +245,7 @@ class FilesQueryBuilder {
|
||||||
List<int>? _byOrDirRowIds;
|
List<int>? _byOrDirRowIds;
|
||||||
List<String>? _byMimePatterns;
|
List<String>? _byMimePatterns;
|
||||||
bool? _byFavorite;
|
bool? _byFavorite;
|
||||||
|
bool? _byArchived;
|
||||||
int? _byDirRowId;
|
int? _byDirRowId;
|
||||||
int? _byServerRowId;
|
int? _byServerRowId;
|
||||||
String? _byLocation;
|
String? _byLocation;
|
||||||
|
|
|
@ -443,6 +443,7 @@ class NpDbSqlite implements NpDb {
|
||||||
List<String>? relativePathKeywords,
|
List<String>? relativePathKeywords,
|
||||||
String? location,
|
String? location,
|
||||||
bool? isFavorite,
|
bool? isFavorite,
|
||||||
|
bool? isArchived,
|
||||||
List<String>? mimes,
|
List<String>? mimes,
|
||||||
TimeRange? timeRange,
|
TimeRange? timeRange,
|
||||||
int? offset,
|
int? offset,
|
||||||
|
@ -458,6 +459,7 @@ class NpDbSqlite implements NpDb {
|
||||||
relativePathKeywords: relativePathKeywords,
|
relativePathKeywords: relativePathKeywords,
|
||||||
location: location,
|
location: location,
|
||||||
isFavorite: isFavorite,
|
isFavorite: isFavorite,
|
||||||
|
isArchived: isArchived,
|
||||||
mimes: mimes,
|
mimes: mimes,
|
||||||
timeRange: timeRange,
|
timeRange: timeRange,
|
||||||
offset: offset,
|
offset: offset,
|
||||||
|
|
Loading…
Reference in a new issue