瀏覽代碼

Update query to select important files

Vishnu Mohandas 4 年之前
父節點
當前提交
09dfe6676a
共有 2 個文件被更改,包括 3 次插入14 次删除
  1. 2 10
      lib/db/files_db.dart
  2. 1 4
      lib/repositories/file_repository.dart

+ 2 - 10
lib/db/files_db.dart

@@ -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);

+ 1 - 4
lib/repositories/file_repository.dart

@@ -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);