π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Handle info item save upload errors
ashilkna8b12adc5088
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arbindex c716764f2e..4659a0bed7 100644--- a/mobile/apps/locker/lib/l10n/app_en.arb+++ b/mobile/apps/locker/lib/l10n/app_en.arb@@ -610,6 +610,14 @@"@uploadFileCountLimitErrorBody": {"description": "Body shown when uploads fail because the locker already has the maximum file count"},+ "uploadFileCountLimitErrorToast": "Action failed. Your individual or family account has hit the 1000-file limit.",+ "@uploadFileCountLimitErrorToast": {+ "description": "Toast shown when info items fail to save due to hitting the file count limit"+ },+ "uploadSubscriptionRequiredErrorBody": "Subscription required to save info items.",+ "@uploadSubscriptionRequiredErrorBody": {+ "description": "Message shown when uploads fail because the user does not have an active subscription"+ },"uploadFileTooLargeErrorTitle": "File too large","@uploadFileTooLargeErrorTitle": {"description": "Title shown when uploads fail because the file exceeds the supported size"diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dartindex 6ea0e937c2..b4c6271b10 100644--- a/mobile/apps/locker/lib/l10n/app_localizations.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart@@ -2038,6 +2038,18 @@ abstract class AppLocalizations {/// **'Your individual or family account has hit the 1000-file limit.'**String get uploadFileCountLimitErrorBody;+ /// Toast shown when info items fail to save due to hitting the file count limit+ ///+ /// In en, this message translates to:+ /// **'Action failed. Your individual or family account has hit the 1000-file limit.'**+ String get uploadFileCountLimitErrorToast;++ /// Message shown when uploads fail because the user does not have an active subscription+ ///+ /// In en, this message translates to:+ /// **'Subscription required to save info items.'**+ String get uploadSubscriptionRequiredErrorBody;+/// Title shown when uploads fail because the file exceeds the supported size////// In en, this message translates to:diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dartindex 5b427aa5e2..8b31fd417a 100644--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart@@ -1143,6 +1143,14 @@ class AppLocalizationsEn extends AppLocalizations {String get uploadFileCountLimitErrorBody =>'Your individual or family account has hit the 1000-file limit.';+ @override+ String get uploadFileCountLimitErrorToast =>+ 'Action failed. Your individual or family account has hit the 1000-file limit.';++ @override+ String get uploadSubscriptionRequiredErrorBody =>+ 'Subscription required to save info items.';+@overrideString get uploadFileTooLargeErrorTitle => 'File too large';diff --git a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dartindex 8009f5c652..cabe0f96ee 100644--- a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart+++ b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart@@ -792,6 +792,18 @@ class FileUploader {file.keyDecryptionNonce = keyDecryptionNonce;file.metadataDecryptionHeader = metadataDecryptionHeader;return file;+ } on DioException catch (e, s) {+ if (_isFileLimitReachedResponse(e.response)) {+ throw FileLimitReachedError();+ }+ final statusCode = e.response?.statusCode;+ if (statusCode == 402) {+ throw NoActiveSubscriptionError();+ } else if (statusCode == 426) {+ throw StorageLimitExceededError();+ }+ _logger.severe("Info file upload failed", e, s);+ rethrow;} catch (e, s) {_logger.severe("Info file upload failed", e, s);rethrow;diff --git a/mobile/apps/locker/lib/ui/pages/base_info_page.dart b/mobile/apps/locker/lib/ui/pages/base_info_page.dartindex 3831dfa2f1..9f274f0153 100644--- a/mobile/apps/locker/lib/ui/pages/base_info_page.dart+++ b/mobile/apps/locker/lib/ui/pages/base_info_page.dart@@ -4,6 +4,7 @@ import 'package:ente_ui/theme/ente_theme.dart';import 'package:ente_ui/utils/toast_util.dart';import 'package:flutter/material.dart';import 'package:flutter/services.dart';+import 'package:locker/core/errors.dart';import 'package:locker/l10n/l10n.dart';import 'package:locker/models/info/info_item.dart';import 'package:locker/services/collections/collections_service.dart';@@ -269,6 +270,20 @@ abstract class BaseInfoPageState<T extends InfoData, W extends BaseInfoPage<T>>);}}+ } on StorageLimitExceededError {+ if (mounted) {+ showToast(+ context,+ context.l10n.uploadStorageLimitErrorBody,+ );+ }+ } on FileLimitReachedError {+ if (mounted) {+ showToast(+ context,+ context.l10n.uploadFileCountLimitErrorToast,+ );+ }} catch (e) {if (mounted) {final errorDetails = () {