π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Implement recovery notice update functionality and enhance UI for recovery sessions
AmanRajSinghMouryaf0ac2220d451
diff --git a/mobile/packages/legacy/lib/pages/emergency_page.dart b/mobile/packages/legacy/lib/pages/emergency_page.dartindex 00a3584dc7..b3fde7cb77 100644--- a/mobile/packages/legacy/lib/pages/emergency_page.dart+++ b/mobile/packages/legacy/lib/pages/emergency_page.dart@@ -138,25 +138,49 @@ class _EmergencyPageState extends State<EmergencyPage> {),);}+ final listIndex = index - 1;final RecoverySessions recoverSession =- info!.recoverSessions[index - 1];- return MenuItemWidgetV2(- captionedTextWidget: CaptionedTextWidgetV2(- title: recoverSession.emergencyContact.email,- makeTextBold: recoverSession.status.isNotEmpty,- textColor: colorScheme.warning500,- ),- leadingIconWidget: UserAvatarWidget(- recoverSession.emergencyContact,- currentUserID: currentUserID,- config: widget.config,- ),- leadingIconSize: 24,- menuItemColor: colorScheme.fillFaint,- trailingIcon: Icons.chevron_right,- onTap: () async {- await showRejectRecoveryDialog(recoverSession);- },+ info!.recoverSessions[listIndex];+ final isLastItem =+ listIndex == info!.recoverSessions.length - 1;+ return Column(+ children: [+ MenuItemWidgetV2(+ captionedTextWidget: CaptionedTextWidgetV2(+ title: recoverSession.emergencyContact.email,+ textStyle: textTheme.small.copyWith(+ color: colorScheme.warning500,+ fontWeight: recoverSession.status.isNotEmpty+ ? FontWeight.bold+ : null,+ ),+ ),+ leadingIconSize: 24.0,+ surfaceExecutionStates: false,+ alwaysShowSuccessState: false,+ leadingIconWidget: UserAvatarWidget(+ recoverSession.emergencyContact,+ type: AvatarType.mini,+ currentUserID: currentUserID,+ config: widget.config,+ ),+ menuItemColor: colorScheme.fillFaint,+ trailingIcon: Icons.chevron_right,+ trailingIconIsMuted: true,+ onTap: () async {+ await showRejectRecoveryDialog(recoverSession);+ },+ isTopBorderRadiusRemoved: listIndex > 0,+ isBottomBorderRadiusRemoved: !isLastItem,+ isFirstItem: listIndex == 0,+ isLastItem: isLastItem,+ ),+ if (!isLastItem)+ DividerWidget(+ dividerType: DividerType.menu,+ bgColor: colorScheme.fillFaint,+ ),+ ],);},childCount: 1 + info!.recoverSessions.length,@@ -431,8 +455,36 @@ class _EmergencyPageState extends State<EmergencyPage> {}}} else if (result?.action == TrustedContactAction.updateTime) {- // TODO: Implement when server API for updating notice period is available- // final selectedDays = result!.selectedDays;+ final selectedDays = result!.selectedDays;+ if (selectedDays == null) return;+ try {+ final success = await EmergencyContactService.instance+ .updateRecoveryNotice(contact, selectedDays);+ if (success) {+ final updatedContact =+ contact.copyWith(recoveryNoticeInDays: selectedDays);+ final index = info?.contacts.indexOf(contact);+ if (index != null && index >= 0) {+ info?.contacts[index] = updatedContact;+ }+ if (mounted) {+ setState(() {});+ }+ } else {+ if (mounted) {+ await showAlertBottomSheet(+ context,+ title: context.strings.cannotUpdateRecoveryTime,+ message: context.strings.cannotUpdateRecoveryTimeMessage,+ assetPath: "assets/warning-blue.png",+ );+ }+ }+ } catch (e) {+ if (mounted) {+ showShortToast(context, context.strings.somethingWentWrong);+ }+ }}}diff --git a/mobile/packages/legacy/lib/services/emergency_service.dart b/mobile/packages/legacy/lib/services/emergency_service.dartindex d0ad15048a..4d6deec779 100644--- a/mobile/packages/legacy/lib/services/emergency_service.dart+++ b/mobile/packages/legacy/lib/services/emergency_service.dart@@ -115,6 +115,34 @@ class EmergencyContactService {}}+ Future<bool> updateRecoveryNotice(+ EmergencyContact contact,+ int recoveryNoticeInDays,+ ) async {+ try {+ await _enteDio.post(+ "/emergency-contacts/update-recovery-notice",+ data: {+ "emergencyContactID": contact.emergencyContact.id,+ "recoveryNoticeInDays": recoveryNoticeInDays,+ },+ );+ return true;+ } on DioException catch (e) {+ if (e.response?.statusCode == 400) {+ final message = e.response?.data?['message'] as String?;+ if (message != null && message.contains('active recovery session')) {+ return false;+ }+ }+ _logger.severe('failed to update recovery notice', e);+ rethrow;+ } catch (e, s) {+ _logger.severe('failed to update recovery notice', e, s);+ rethrow;+ }+ }+Future<void> startRecovery(EmergencyContact contact) async {try {await _enteDio.post(diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex 07230242b7..9df2df8c73 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -815,6 +815,8 @@"addTrustedContact": "Add trusted contact","removeInvite": "Remove invite","rejectRecovery": "Reject recovery",+ "cannotUpdateRecoveryTime": "Cannot update recovery time",+ "cannotUpdateRecoveryTimeMessage": "Recovery time cannot be changed while there is an active recovery session. Please reject or wait for the recovery to complete.","recoveryInitiated": "Recovery initiated","recoveryInitiatedDesc": "You can access the account after {days} days. A notification will be sent to {email}.","@recoveryInitiatedDesc": {