Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix sync state issue

AmanRajSinghMouryae7368109053c
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index b0fff853fa..b87c212931 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -496,16 +496,25 @@ class _HomePageState extends UploaderPageState<HomePage>
});
}
- final collections = await CollectionService.instance.getCollections();
+ var collections = await CollectionService.instance.getCollections();
await _loadRecentFiles(collections);
- final sortedCollections =
- CollectionSortUtil.getSortedCollections(collections);
-
- // Only mark initial load complete when first sync has finished
- // This prevents empty state while sync is in progress
+ // If collections are empty and first sync is complete, ensure default
+ // collections are created. This handles the case where default collections
+ // setup was skipped during initialization due to the master key not being
+ // available yet.
final hasCompletedFirstSync =
CollectionService.instance.hasCompletedFirstSync();
+ if (collections.isEmpty && hasCompletedFirstSync) {
+ _logger.info("No collections found after sync, setting up defaults");
+ await CollectionService.instance.setupDefaultCollections();
+ // Reload collections after setup
+ collections = await CollectionService.instance.getCollections();
+ await _loadRecentFiles(collections);
+ }
+
+ final sortedCollections =
+ CollectionSortUtil.getSortedCollections(collections);
if (mounted) {
setState(() {