Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix: Hide both shared and collect files

Neeraj Gupta856e126bc8cf
diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dart
index ae702d92b4..fb8cb72541 100644
--- a/mobile/lib/db/files_db.dart
+++ b/mobile/lib/db/files_db.dart
@@ -640,7 +640,6 @@ class FilesDB with SqlDbBase {
int visibility = visibleVisibility,
DBFilterOptions? filterOptions,
bool applyOwnerCheck = false,
- bool ignoreSharedFiles = false,
}) async {
final stopWatch = EnteWatch('getAllPendingOrUploadedFiles')..start();
final order = (asc ?? false ? 'ASC' : 'DESC');
@@ -663,7 +662,7 @@ class FilesDB with SqlDbBase {
subQueries.add(' AND $columnMMdVisibility = ?');
args.add(visibility);
- if (ignoreSharedFiles == true) {
+ if (filterOptions?.ignoreSharedItems ?? false) {
subQueries.add(' AND $columnOwnerID = ?');
args.add(ownerID);
}
@@ -696,7 +695,6 @@ class FilesDB with SqlDbBase {
int ownerID, {
int? limit,
bool? asc,
- bool ignoreSharedFiles = false,
required DBFilterOptions filterOptions,
}) async {
final db = await instance.sqliteAsyncDB;
@@ -708,7 +706,7 @@ class FilesDB with SqlDbBase {
'SELECT * FROM $filesTable WHERE $columnCreationTime >= ? AND $columnCreationTime <= ? AND ($columnMMdVisibility IS NULL OR $columnMMdVisibility = ?)'
' AND ($columnLocalID IS NOT NULL OR ($columnCollectionID IS NOT NULL AND $columnCollectionID IS NOT -1))');
- if (ignoreSharedFiles == true) {
+ if (filterOptions.ignoreSharedItems) {
subQueries.add(' AND $columnOwnerID = ?');
args.add(ownerID);
}
diff --git a/mobile/lib/services/filter/db_filters.dart b/mobile/lib/services/filter/db_filters.dart
index 5329b4825c..a4ec0bce9d 100644
--- a/mobile/lib/services/filter/db_filters.dart
+++ b/mobile/lib/services/filter/db_filters.dart
@@ -4,6 +4,7 @@ import "package:photos/services/filter/collection_ignore.dart";
import "package:photos/services/filter/dedupe_by_upload_id.dart";
import "package:photos/services/filter/filter.dart";
import "package:photos/services/filter/only_uploaded_files_filter.dart";
+import "package:photos/services/filter/shared.dart";
import "package:photos/services/filter/upload_ignore.dart";
import "package:photos/services/ignored_files_service.dart";
@@ -18,12 +19,16 @@ class DBFilterOptions {
bool ignoreSavedFiles;
bool onlyUploadedFiles;
+ // If true, files owned by other users or uploaded by other users will be ignored.
+ bool ignoreSharedItems = false;
+
DBFilterOptions({
this.ignoredCollectionIDs,
this.hideIgnoredForUpload = false,
this.dedupeUploadID = true,
this.ignoreSavedFiles = false,
this.onlyUploadedFiles = false,
+ this.ignoreSharedItems = false,
});
static DBFilterOptions dedupeOption = DBFilterOptions(
@@ -39,6 +44,9 @@ Future<List<EnteFile>> applyDBFilters(
return files;
}
final List<Filter> filters = [];
+ if (options.ignoreSharedItems) {
+ filters.add(SkipSharedFileFilter());
+ }
if (options.hideIgnoredForUpload) {
final Map<String, String> idToReasonMap =
await IgnoredFilesService.instance.idToIgnoreReasonMap;
diff --git a/mobile/lib/services/filter/shared.dart b/mobile/lib/services/filter/shared.dart
new file mode 100644
index 0000000000..823573ff88
--- /dev/null
+++ b/mobile/lib/services/filter/shared.dart
@@ -0,0 +1,10 @@
+import "package:photos/models/file/extensions/file_props.dart";
+import "package:photos/models/file/file.dart";
+import "package:photos/services/filter/filter.dart";
+
+class SkipSharedFileFilter extends Filter {
+ @override
+ bool filter(EnteFile file) {
+ return file.uploaderName == null && file.isOwner;
+ }
+}
diff --git a/mobile/lib/ui/home/home_gallery_widget.dart b/mobile/lib/ui/home/home_gallery_widget.dart
index 35bc5eb326..0ece05ba72 100644
--- a/mobile/lib/ui/home/home_gallery_widget.dart
+++ b/mobile/lib/ui/home/home_gallery_widget.dart
@@ -88,6 +88,7 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
dedupeUploadID: true,
ignoredCollectionIDs: collectionsToHide,
ignoreSavedFiles: true,
+ ignoreSharedItems: _shouldHideSharedItems,
);
if (hasSelectedAllForBackup) {
result = await FilesDB.instance.getAllLocalAndUploadedFiles(
@@ -97,7 +98,6 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
limit: limit,
asc: asc,
filterOptions: filterOptions,
- ignoreSharedFiles: _shouldHideSharedItems,
);
} else {
result = await FilesDB.instance.getAllPendingOrUploadedFiles(
@@ -107,7 +107,6 @@ class _HomeGalleryWidgetState extends State<HomeGalleryWidget> {
limit: limit,
asc: asc,
filterOptions: filterOptions,
- ignoreSharedFiles: _shouldHideSharedItems,
);
}