π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos]Fix: Show fav icon on shared photos
Neeraj Gupta3788fdda6f36
diff --git a/mobile/lib/db/files_db.dart b/mobile/lib/db/files_db.dartindex 202faaaad9..af544e6c13 100644--- a/mobile/lib/db/files_db.dart+++ b/mobile/lib/db/files_db.dart@@ -539,6 +539,28 @@ class FilesDB {return ids;}+ Future<(Set<int>, Set<String>)> getUploadAndHash(int collectionID) async {+ final db = await instance.database;+ final results = await db.query(+ filesTable,+ columns: [columnUploadedFileID, columnHash],+ where:+ '$columnCollectionID = ? AND ($columnUploadedFileID IS NOT NULL AND $columnUploadedFileID IS NOT -1)',+ whereArgs: [+ collectionID,+ ],+ );+ final ids = <int>{};+ final hash = <String>{};+ for (final result in results) {+ ids.add(result[columnUploadedFileID] as int);+ if (result[columnHash] != null) {+ hash.add(result[columnHash] as String);+ }+ }+ return (ids, hash);+ }+Future<BackedUpFileIDs> getBackedUpIDs() async {final db = await instance.database;final results = await db.query(diff --git a/mobile/lib/services/collections_service.dart b/mobile/lib/services/collections_service.dartindex 8036d3f0de..44777705d0 100644--- a/mobile/lib/services/collections_service.dart+++ b/mobile/lib/services/collections_service.dart@@ -1610,10 +1610,13 @@ class CollectionsService {for (final file in batch) {params["fileIDs"].add(file.uploadedFileID);}- await _enteDio.post(+ final resp = await _enteDio.post("/collections/v3/remove-files",data: params,);+ if (resp.statusCode != 200) {+ throw Exception("Failed to remove files from collection");+ }await _filesDB.removeFromCollection(collectionID, params["fileIDs"]);Bus.instancediff --git a/mobile/lib/services/favorites_service.dart b/mobile/lib/services/favorites_service.dartindex c5ec0e851b..0ed6c030a6 100644--- a/mobile/lib/services/favorites_service.dart+++ b/mobile/lib/services/favorites_service.dart@@ -24,6 +24,7 @@ class FavoritesService {late FilesDB _filesDB;int? _cachedFavoritesCollectionID;final Set<int> _cachedFavUploadedIDs = {};+ final Set<String> _cachedFavFileHases = {};final Set<String> _cachedPendingLocalIDs = {};late StreamSubscription<CollectionUpdatedEvent>_collectionUpdatesSubscription;@@ -60,9 +61,12 @@ class FavoritesService {Future<void> _warmUpCache() async {final favCollection = await _getFavoritesCollection();if (favCollection != null) {- final uploadedIDs =- await FilesDB.instance.getUploadedFileIDs(favCollection.id);+ Set<int> uploadedIDs;+ Set<String> fileHashes;+ (uploadedIDs, fileHashes) =+ await FilesDB.instance.getUploadAndHash(favCollection.id);_cachedFavUploadedIDs.addAll(uploadedIDs);+ _cachedFavFileHases.addAll(fileHashes);}}@@ -87,6 +91,9 @@ class FavoritesService {return false;}if (file.uploadedFileID != null) {+ if (file.ownerID != _config.getUserID() && file.hash != null) {+ return _cachedFavFileHases.contains(file.hash!);+ }return _cachedFavUploadedIDs.contains(file.uploadedFileID);} else if (file.localID != null) {return _cachedPendingLocalIDs.contains(file.localID);@@ -99,6 +106,9 @@ class FavoritesService {if (collection == null || file.uploadedFileID == null) {return false;}+ if (file.ownerID != _config.getUserID() && file.hash != null) {+ return _cachedFavFileHases.contains(file.hash!);+ }return _filesDB.doesFileExistInCollection(file.uploadedFileID!,collection.id,@@ -110,10 +120,14 @@ class FavoritesService {required bool favFlag,}) {final Set<int> updatedIDs = {};+ final Set<String> hashes = {};final Set<String> localIDs = {};for (var file in files) {if (file.uploadedFileID != null) {updatedIDs.add(file.uploadedFileID!);+ if (file.hash != null) {+ hashes.add(file.hash!);+ }} else if (file.localID != null || file.localID != "") {/* Note: Favorite un-uploaded filesFor such files, as we don't have uploaded IDs yet, we will cache@@ -124,8 +138,10 @@ class FavoritesService {}if (favFlag) {_cachedFavUploadedIDs.addAll(updatedIDs);+ _cachedFavFileHases.addAll(hashes);} else {_cachedFavUploadedIDs.removeAll(updatedIDs);+ _cachedFavFileHases.removeAll(hashes);}}