Update query to select important files

This commit is contained in:
Vishnu Mohandas 2020-10-26 15:58:05 +05:30
parent 76e6f1fb60
commit 09dfe6676a
2 changed files with 3 additions and 14 deletions

View file

@ -120,19 +120,11 @@ class FilesDB {
return _convertToFiles(results)[0];
}
Future<List<File>> getOwnedFiles(int ownerID) async {
Future<List<File>> getFiles() async {
final db = await instance.database;
final whereArgs = List<dynamic>();
if (ownerID != null) {
whereArgs.add(ownerID);
}
final results = await db.query(
table,
where: '$columnIsDeleted = 0' +
(ownerID == null
? ''
: ' AND ($columnOwnerID IS NULL OR $columnOwnerID = ?)'),
whereArgs: whereArgs,
where: '$columnIsDeleted = 0',
orderBy: '$columnCreationTime DESC',
);
return _convertToFiles(results);

View file

@ -1,5 +1,4 @@
import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/event_bus.dart';
import 'package:photos/db/files_db.dart';
import 'package:photos/events/local_photos_updated_event.dart';
@ -17,9 +16,7 @@ class FileRepository {
}
Future<List<File>> loadFiles() async {
var files = await FilesDB.instance
.getOwnedFiles(Configuration.instance.getUserID());
var files = await FilesDB.instance.getFiles();
_files.clear();
_files.addAll(files);