π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Gracefully handle url-update err
Neeraj Guptac88c97e22d26
diff --git a/mobile/apps/photos/lib/core/errors.dart b/mobile/apps/photos/lib/core/errors.dartindex 10e220043e..d6165065cc 100644--- a/mobile/apps/photos/lib/core/errors.dart+++ b/mobile/apps/photos/lib/core/errors.dart@@ -78,6 +78,8 @@ class SrpSetupNotCompleteError extends Error {}class SharingNotPermittedForFreeAccountsError extends Error {}+class LinkEditNotAllowedError extends Error {}+class NoMediaLocationAccessError extends Error {}class PassKeySessionNotVerifiedError extends Error {}diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 3a42067ee1..e9a020d3b3 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -357,6 +357,7 @@"sorryCouldNotAddToFavorites": "Sorry, could not add to favorites!","sorryCouldNotRemoveFromFavorites": "Sorry, could not remove from favorites!","subscribeToEnableSharing": "You need an active paid subscription to enable sharing.",+ "subscribeToChangeLinkSetting": "You need a paid subscription to change this link setting.","subscribe": "Subscribe","canOnlyRemoveFilesOwnedByYou": "Can only remove files owned by you","deleteSharedAlbum": "Delete shared album?",diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dartindex 161f845ba4..a7002703e9 100644--- a/mobile/apps/photos/lib/services/collections_service.dart+++ b/mobile/apps/photos/lib/services/collections_service.dart@@ -1277,6 +1277,10 @@ class CollectionsService {if (e.response?.statusCode == 402) {throw SharingNotPermittedForFreeAccountsError();}+ if (e.response?.statusCode == 403 &&+ e.response?.data?['code'] == 'LINK_EDIT_NOT_ALLOWED') {+ throw LinkEditNotAllowedError();+ }rethrow;} catch (e, s) {_logger.severe("failed to update ShareUrl", e, s);@@ -2213,9 +2217,21 @@ class CollectionsService {}await _filesDB.removeFromCollection(collectionID, params["fileIDs"]);- Bus.instance- .fire(CollectionUpdatedEvent(collectionID, batch, "removeFrom", type: EventType.deletedFromRemote,));- Bus.instance.fire(LocalPhotosUpdatedEvent(batch, source: "removeFrom", type: EventType.deletedFromRemote,));+ Bus.instance.fire(+ CollectionUpdatedEvent(+ collectionID,+ batch,+ "removeFrom",+ type: EventType.deletedFromRemote,+ ),+ );+ Bus.instance.fire(+ LocalPhotosUpdatedEvent(+ batch,+ source: "removeFrom",+ type: EventType.deletedFromRemote,+ ),+ );}RemoteSyncService.instance.sync(silently: true).ignore();}@@ -2250,7 +2266,13 @@ class CollectionsService {type: EventType.deletedFromRemote,),);- Bus.instance.fire(LocalPhotosUpdatedEvent(files, source: "suggestDelete", type: EventType.deletedFromRemote,));+ Bus.instance.fire(+ LocalPhotosUpdatedEvent(+ files,+ source: "suggestDelete",+ type: EventType.deletedFromRemote,+ ),+ );RemoteSyncService.instance.sync(silently: true).ignore();}diff --git a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dartindex a309706713..ed628ab75e 100644--- a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart+++ b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart@@ -5,6 +5,7 @@ import 'package:ente_crypto/ente_crypto.dart';import 'package:ente_qr_ui/ente_qr_ui.dart';import 'package:flutter/material.dart';import "package:flutter/services.dart";+import "package:photos/core/errors.dart";import "package:photos/generated/l10n.dart";import "package:photos/models/api/collection/public_url.dart";import 'package:photos/models/collection/collection.dart';@@ -12,12 +13,16 @@ import 'package:photos/services/collections_service.dart';import 'package:photos/theme/colors.dart';import 'package:photos/theme/ente_theme.dart';import 'package:photos/ui/actions/collection/collection_sharing_actions.dart';+import 'package:photos/ui/components/buttons/button_widget.dart';import 'package:photos/ui/components/captioned_text_widget.dart';+import 'package:photos/ui/components/dialog_widget.dart';import 'package:photos/ui/components/divider_widget.dart';import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';import 'package:photos/ui/components/menu_section_description_widget.dart';+import 'package:photos/ui/components/models/button_type.dart';import "package:photos/ui/components/toggle_switch_widget.dart";import 'package:photos/ui/notification/toast.dart';+import 'package:photos/ui/payment/subscription.dart';import 'package:photos/ui/sharing/pickers/device_limit_picker_page.dart';import 'package:photos/ui/sharing/pickers/layout_picker_page.dart';import 'package:photos/ui/sharing/pickers/link_expiry_picker_page.dart';@@ -487,8 +492,45 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {}} catch (e) {await dialog?.hide();- await showGenericErrorDialog(context: context, error: e);+ if (e is LinkEditNotAllowedError) {+ await _showLinkEditNotAllowedDialog(context);+ } else {+ await showGenericErrorDialog(context: context, error: e);+ }rethrow;}}++ Future<void> _showLinkEditNotAllowedDialog(BuildContext context) async {+ final buttonResult = await showDialogWidget(+ context: context,+ title: AppLocalizations.of(context).sorry,+ body: AppLocalizations.of(context).subscribeToChangeLinkSetting,+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.primary,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.first,+ labelText: AppLocalizations.of(context).subscribe,+ ),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ buttonAction: ButtonAction.cancel,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ labelText: AppLocalizations.of(context).ok,+ ),+ ],+ );+ if (buttonResult?.action == ButtonAction.first) {+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return getSubscriptionPage();+ },+ ),+ );+ }+ }}diff --git a/mobile/apps/photos/lib/ui/sharing/pickers/device_limit_picker_page.dart b/mobile/apps/photos/lib/ui/sharing/pickers/device_limit_picker_page.dartindex 36aaef0345..6c9f7127d0 100644--- a/mobile/apps/photos/lib/ui/sharing/pickers/device_limit_picker_page.dart+++ b/mobile/apps/photos/lib/ui/sharing/pickers/device_limit_picker_page.dart@@ -1,14 +1,19 @@import 'package:flutter/material.dart';import 'package:photos/core/constants.dart';+import "package:photos/core/errors.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/collection/collection.dart';import 'package:photos/services/collections_service.dart';import 'package:photos/theme/ente_theme.dart';+import 'package:photos/ui/components/buttons/button_widget.dart';import 'package:photos/ui/components/captioned_text_widget.dart';+import 'package:photos/ui/components/dialog_widget.dart';import 'package:photos/ui/components/divider_widget.dart';import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';+import 'package:photos/ui/components/models/button_type.dart';import 'package:photos/ui/components/title_bar_title_widget.dart';import 'package:photos/ui/components/title_bar_widget.dart';+import 'package:photos/ui/payment/subscription.dart';import 'package:photos/utils/dialog_util.dart';import 'package:photos/utils/separators_util.dart';@@ -139,8 +144,45 @@ class _ItemsWidgetState extends State<ItemsWidget> {try {await CollectionsService.instance.updateShareUrl(widget.collection, prop);} catch (e) {- await showGenericErrorDialog(context: context, error: e);+ if (e is LinkEditNotAllowedError) {+ await _showLinkEditNotAllowedDialog(context);+ } else {+ await showGenericErrorDialog(context: context, error: e);+ }rethrow;}}++ Future<void> _showLinkEditNotAllowedDialog(BuildContext context) async {+ final buttonResult = await showDialogWidget(+ context: context,+ title: AppLocalizations.of(context).sorry,+ body: AppLocalizations.of(context).subscribeToChangeLinkSetting,+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.primary,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.first,+ labelText: AppLocalizations.of(context).subscribe,+ ),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ buttonAction: ButtonAction.cancel,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ labelText: AppLocalizations.of(context).ok,+ ),+ ],+ );+ if (buttonResult?.action == ButtonAction.first) {+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return getSubscriptionPage();+ },+ ),+ );+ }+ }}diff --git a/mobile/apps/photos/lib/ui/sharing/pickers/link_expiry_picker_page.dart b/mobile/apps/photos/lib/ui/sharing/pickers/link_expiry_picker_page.dartindex 4af5af5cf4..2ac4ada91f 100644--- a/mobile/apps/photos/lib/ui/sharing/pickers/link_expiry_picker_page.dart+++ b/mobile/apps/photos/lib/ui/sharing/pickers/link_expiry_picker_page.dart@@ -1,13 +1,18 @@import 'package:flutter/material.dart';+import "package:photos/core/errors.dart";import "package:photos/generated/l10n.dart";import 'package:photos/models/collection/collection.dart';import 'package:photos/services/collections_service.dart';import 'package:photos/theme/ente_theme.dart';+import 'package:photos/ui/components/buttons/button_widget.dart';import 'package:photos/ui/components/captioned_text_widget.dart';+import 'package:photos/ui/components/dialog_widget.dart';import 'package:photos/ui/components/divider_widget.dart';import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';+import 'package:photos/ui/components/models/button_type.dart';import 'package:photos/ui/components/title_bar_title_widget.dart';import 'package:photos/ui/components/title_bar_widget.dart';+import 'package:photos/ui/payment/subscription.dart';import "package:photos/ui/viewer/date/date_time_picker.dart";import 'package:photos/utils/dialog_util.dart';import 'package:photos/utils/separators_util.dart';@@ -175,8 +180,45 @@ class _ItemsWidgetState extends State<ItemsWidget> {try {await CollectionsService.instance.updateShareUrl(widget.collection, prop);} catch (e) {- await showGenericErrorDialog(context: context, error: e);+ if (e is LinkEditNotAllowedError) {+ await _showLinkEditNotAllowedDialog(context);+ } else {+ await showGenericErrorDialog(context: context, error: e);+ }rethrow;}}++ Future<void> _showLinkEditNotAllowedDialog(BuildContext context) async {+ final buttonResult = await showDialogWidget(+ context: context,+ title: AppLocalizations.of(context).sorry,+ body: AppLocalizations.of(context).subscribeToChangeLinkSetting,+ buttons: [+ ButtonWidget(+ buttonType: ButtonType.primary,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ buttonAction: ButtonAction.first,+ labelText: AppLocalizations.of(context).subscribe,+ ),+ ButtonWidget(+ buttonType: ButtonType.secondary,+ buttonAction: ButtonAction.cancel,+ isInAlert: true,+ shouldStickToDarkTheme: true,+ labelText: AppLocalizations.of(context).ok,+ ),+ ],+ );+ if (buttonResult?.action == ButtonAction.first) {+ await Navigator.of(context).push(+ MaterialPageRoute(+ builder: (BuildContext context) {+ return getSubscriptionPage();+ },+ ),+ );+ }+ }}