Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix flickering on all collection page

AmanRajSinghMourya482ebd418a31
diff --git a/mobile/apps/locker/lib/services/collections/collections_api_client.dart b/mobile/apps/locker/lib/services/collections/collections_api_client.dart
index 802e06acba..f7f25fd314 100644
--- a/mobile/apps/locker/lib/services/collections/collections_api_client.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_api_client.dart
@@ -236,7 +236,6 @@ class CollectionApiClient {
await _db.deleteCollection(collection);
final deletedCollection = collection.copyWith(isDeleted: true);
await _updateCollectionInDB(deletedCollection);
- Bus.instance.fire(CollectionsUpdatedEvent("delete_collection"));
}
Future<void> move(
diff --git a/mobile/apps/locker/lib/services/collections/collections_service.dart b/mobile/apps/locker/lib/services/collections/collections_service.dart
index 61fd5ef64a..aaccd30993 100644
--- a/mobile/apps/locker/lib/services/collections/collections_service.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_service.dart
@@ -381,8 +381,9 @@ class CollectionService {
Future<void> move(
List<EnteFile> files,
Collection from,
- Collection to,
- ) async {
+ Collection to, {
+ bool runSync = true,
+ }) async {
if (files.isEmpty) {
_logger.info("No files to move");
return;
@@ -403,12 +404,11 @@ class CollectionService {
// Add to target collection
await _db.addFilesToCollection(to, files);
-
- // Fire event to update UI
- Bus.instance.fire(CollectionsUpdatedEvent('files_moved'));
-
+
// Let sync update the local state to ensure consistency
- await sync();
+ if (runSync) {
+ await sync();
+ }
} catch (e, stackTrace) {
_logger.severe("Failed to move files: $e", e, stackTrace);
rethrow;
@@ -627,6 +627,7 @@ class CollectionService {
entry.value,
collection,
toCollection,
+ runSync: false,
);
}
}
diff --git a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
index 778668ff75..df6091c94a 100644
--- a/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/all_collections_page.dart
@@ -51,7 +51,7 @@ class _AllCollectionsPageState extends State<AllCollectionsPage> {
_collectionsUpdatedSub =
Bus.instance.on<CollectionsUpdatedEvent>().listen((event) async {
if (!mounted) return;
- await _loadCollections();
+ await _loadCollections(showLoading: false);
});
if (widget.viewType == UISectionType.homeCollections) {
showTrash = true;
@@ -65,8 +65,8 @@ class _AllCollectionsPageState extends State<AllCollectionsPage> {
super.dispose();
}
- Future<void> _loadCollections() async {
- if (mounted) {
+ Future<void> _loadCollections({bool showLoading = true}) async {
+ if (mounted && showLoading) {
setState(() {
_isLoading = true;
_error = null;
@@ -115,13 +115,17 @@ class _AllCollectionsPageState extends State<AllCollectionsPage> {
: 0;
if (mounted) {
- setState(() {
- _isLoading = false;
- });
+ if (showLoading) {
+ setState(() {
+ _isLoading = false;
+ });
+ } else {
+ setState(() {});
+ }
}
} catch (e) {
_logger.severe("Failed to load collections", e);
- if (mounted) {
+ if (mounted && showLoading) {
setState(() {
_error = context.l10n.failedToLoadCollections(e.toString());
_isLoading = false;