Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Add a new parameter 'ignoreSharedFiles' and use that instead of passing 'applyOwnerCheck' since apply owner check doesn't exclude files for which ownerID is null

ashilkna1afd8155c26
diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart
index a47e4ea744..c50350a78d 100644
--- a/mobile/lib/db/files_db.dart
+++ b/mobile/lib/db/files_db.dart
@@ -674,35 +674,47 @@ class FilesDB {
int visibility = visibleVisibility,
DBFilterOptions? filterOptions,
bool applyOwnerCheck = false,
+ bool ignoreSharedFiles = false,
}) async {
final stopWatch = EnteWatch('getAllPendingOrUploadedFiles')..start();
final order = (asc ?? false ? 'ASC' : 'DESC');
- late String query;
+ final subQueries = <String>[];
late List<Object?>? args;
if (applyOwnerCheck) {
- query =
+ subQueries.add(
'SELECT * FROM $filesTable WHERE $columnCreationTime >= ? AND $columnCreationTime <= ? '
'AND ($columnOwnerID IS NULL OR $columnOwnerID = ?) '
- 'AND ($columnCollectionID IS NOT NULL AND $columnCollectionID IS NOT -1)'
- ' AND $columnMMdVisibility = ? ORDER BY $columnCreationTime $order, $columnModificationTime $order';
-
- args = [startTime, endTime, ownerID, visibility];
+ 'AND ($columnCollectionID IS NOT NULL AND $columnCollectionID IS NOT -1)');
+ args = [startTime, endTime, ownerID];
} else {
- query =
+ subQueries.add(
'SELECT * FROM $filesTable WHERE $columnCreationTime >= ? AND $columnCreationTime <= ? '
- 'AND ($columnCollectionID IS NOT NULL AND $columnCollectionID IS NOT -1)'
- ' AND $columnMMdVisibility = ? ORDER BY $columnCreationTime $order, $columnModificationTime $order';
- args = [startTime, endTime, visibility];
+ 'AND ($columnCollectionID IS NOT NULL AND $columnCollectionID IS NOT -1)');
+ args = [startTime, endTime];
+ }
+
+ subQueries.add(' AND $columnMMdVisibility = ?');
+ args.add(visibility);
+
+ if (ignoreSharedFiles == true) {
+ subQueries.add(' AND $columnOwnerID = ?');
+ args.add(ownerID);
}
+ subQueries.add(
+ ' ORDER BY $columnCreationTime $order, $columnModificationTime $order',
+ );
+
if (limit != null) {
- query += ' LIMIT ?';
+ subQueries.add(' LIMIT ?');
args.add(limit);
}
+ final finalQuery = subQueries.join();
+
final db = await instance.sqliteAsyncDB;
- final results = await db.getAll(query, args);
+ final results = await db.getAll(finalQuery, args);
stopWatch.log('queryDone');
final files = convertToFiles(results);
stopWatch.log('convertDone');
diff --git a/mobile/lib/ui/home/home_gallery_widget.dart b/mobile/lib/ui/home/home_gallery_widget.dart
index 2307633b3e..067cb5cc0d 100644
--- a/mobile/lib/ui/home/home_gallery_widget.dart
+++ b/mobile/lib/ui/home/home_gallery_widget.dart
@@ -105,7 +105,7 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
limit: limit,
asc: asc,
filterOptions: filterOptions,
- applyOwnerCheck: _shouldHideSharedItems,
+ ignoreSharedFiles: _shouldHideSharedItems,
);
}