π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Improve error logging and handle uncategorized uploads in UploaderPage
AmanRajSinghMouryad0b383ae6448
diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dartindex 555a473d50..892fced891 100644--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart@@ -131,7 +131,7 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>}}} catch (e) {- _logger.severe('Error updating collection: $e');+ _logger.severe('Error updating collection', e);}});diff --git a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dartindex d6043819a6..25e6d54b42 100644--- a/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart+++ b/mobile/apps/locker/lib/ui/pages/file_upload_screen.dart@@ -283,6 +283,8 @@ class _FileUploadScreenState extends State<FileUploadScreen> {void _onUncategorizedSelected() {setState(() {+ // Clear all collections - empty set represents "uncategorized"+ // This will be interpreted as uploading to uncategorized collection_selectedCollections.clear();});}diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dartindex ecd2248702..fa4e453497 100644--- a/mobile/apps/locker/lib/ui/pages/home_page.dart+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart@@ -217,11 +217,7 @@ class _HomePageState extends UploaderPageState<HomePage>@overridevoid onFileUploadComplete() {- // No-op: CollectionService.sync() already fires CollectionsUpdatedEvent- // which triggers a single refresh. Avoid calling _loadCollections here to- // prevent duplicate reloads / UI blinking when uploading to multiple- // collections.- return;+ _loadCollections();}@override@@ -630,20 +626,20 @@ class _HomePageState extends UploaderPageState<HomePage>);}- if (_displayedCollections.isEmpty) {+ // Show empty state only if both collections and recent files are empty+ if (_displayedCollections.isEmpty && _recentFiles.isEmpty) {final colorScheme = getEnteColorScheme(context);final textTheme = getEnteTextTheme(context);- return Center(- child: SingleChildScrollView(- physics: const AlwaysScrollableScrollPhysics(),- padding: const EdgeInsets.symmetric(horizontal: 16),+ return Container(+ padding: const EdgeInsets.symmetric(vertical: 40),+ child: Center(child: SizedBox(width: double.infinity,child: Container(decoration: BoxDecoration(- borderRadius: BorderRadius.circular(24),color: colorScheme.backdropBase,+ borderRadius: BorderRadius.circular(24),),child: DottedBorder(options: RoundedRectDottedBorderOptions(@@ -723,58 +719,6 @@ class _HomePageState extends UploaderPageState<HomePage>}Widget _buildRecentsSection() {- final colorScheme = getEnteColorScheme(context);- final textTheme = getEnteTextTheme(context);-- if (_recentFiles.isEmpty) {- return Container(- padding: const EdgeInsets.symmetric(vertical: 40),- child: Center(- child: SizedBox(- width: double.infinity,- child: Container(- decoration: BoxDecoration(- color: colorScheme.backdropBase,- borderRadius: BorderRadius.circular(24),- ),- child: DottedBorder(- options: RoundedRectDottedBorderOptions(- strokeWidth: 2,- color: colorScheme.fillMuted,- dashPattern: const [6, 6],- radius: const Radius.circular(24),- padding: const EdgeInsets.all(48),- ),- child: Center(- child: Column(- mainAxisSize: MainAxisSize.min,- crossAxisAlignment: CrossAxisAlignment.center,- children: [- Image.asset(- 'assets/empty_state.png',- ),- const SizedBox(height: 16),- Text(- 'Upload a File',- style: textTheme.h3Bold,- ),- const SizedBox(height: 4),- GestureDetector(- onTap: addFile,- child: Text(- 'Click here to upload',- style: textTheme.small,- ),- ),- ],- ),- ),- ),- ),- ),- ),- );- }return RecentsSectionWidget(collections: _filterOutUncategorized(_collections),recentFiles: _recentFiles,@@ -966,6 +910,7 @@ class _HomePageState extends UploaderPageState<HomePage>required List<Collection> collections,required UISectionType viewType,}) {+ final colorScheme = getEnteColorScheme(context);return [SectionOptions(onTap: () {@@ -983,7 +928,7 @@ class _HomePageState extends UploaderPageState<HomePage>trailingWidget: IconButtonWidget(icon: Icons.chevron_right,iconButtonType: IconButtonType.secondary,- iconColor: getEnteColorScheme(context).textBase,+ iconColor: colorScheme.textBase,),),const SizedBox(height: 24),diff --git a/mobile/apps/locker/lib/ui/pages/uploader_page.dart b/mobile/apps/locker/lib/ui/pages/uploader_page.dartindex 7d03d9861e..4cb12249a4 100644--- a/mobile/apps/locker/lib/ui/pages/uploader_page.dart+++ b/mobile/apps/locker/lib/ui/pages/uploader_page.dart@@ -59,7 +59,6 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {final List<Future> futures = [];final collections = await CollectionService.instance.getCollections();-final collectionsWithoutUncategorized = collections.where((c) => c.type != CollectionType.uncategorized).toList();@@ -76,7 +75,22 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {),);- if (uploadResult != null && uploadResult.selectedCollections.isNotEmpty) {+ // Handle both regular collections and uncategorized (empty set)+ final isUncategorizedUpload =+ uploadResult != null && uploadResult.selectedCollections.isEmpty;+ final isRegularUpload =+ uploadResult != null && uploadResult.selectedCollections.isNotEmpty;++ if (isUncategorizedUpload || isRegularUpload) {+ if (isUncategorizedUpload) {+ // Get the uncategorized collection for upload+ final uncategorizedCollection = await CollectionService.instance+ .getOrCreateUncategorizedCollection();+ uploadResult.selectedCollections.add(uncategorizedCollection);+ }++ await progressDialog.show();+int completedUploads = 0;for (final file in files) {final fileUploadFuture = FileUploader.instance@@ -112,6 +126,7 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {}}).catchError((e) {completedUploads++;+ _logger.severe('File upload failed', e);progressDialog.update(message: context.l10n.uploadedFilesProgressWithError(completedUploads,@@ -122,18 +137,15 @@ abstract class UploaderPageState<T extends UploaderPage> extends State<T> {}),);}- }- if (futures.isNotEmpty) {- await progressDialog.show();- await Future.wait(futures);- // Sync once at the end when files are added to multiple collections- final shouldPerformFinalSync = (uploadResult != null &&- uploadResult.selectedCollections.length > 1);+ if (futures.isNotEmpty) {+ await Future.wait(futures);++ onFileUploadComplete();- if (shouldPerformFinalSync) {- // Final sync triggers UI refresh via CollectionsUpdatedEvent- await CollectionService.instance.sync();+ await CollectionService.instance.sync().catchError((e) {+ _logger.warning('Background sync failed after upload', e);+ });}}} catch (e, s) {