From 4f942bc182b301df7c89159a49bb418267ae6b14 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:32:09 +0000 Subject: [PATCH] fix(mobile): copy shared link (#6310) * fix(mobile): copy shared link * fix: handle trailing slash --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> --- mobile/assets/i18n/en-US.json | 1 - .../shared_link/ui/shared_link_item.dart | 9 +++++---- .../views/shared_link_edit_page.dart | 17 ++++++----------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/mobile/assets/i18n/en-US.json b/mobile/assets/i18n/en-US.json index 7c3fd35cb4..4eb8693475 100644 --- a/mobile/assets/i18n/en-US.json +++ b/mobile/assets/i18n/en-US.json @@ -378,7 +378,6 @@ "share_dialog_preparing": "Preparing...", "shared_link_app_bar_title": "Shared Links", "shared_link_clipboard_copied_massage": "Copied to clipboard", - "shared_link_clipboard_text": "Link: {}\nPassword: {}", "shared_link_create_app_bar_title": "Create link to share", "shared_link_create_error": "Error while creating shared link", "shared_link_create_info": "Let anyone with the link see the selected photo(s)", diff --git a/mobile/lib/modules/shared_link/ui/shared_link_item.dart b/mobile/lib/modules/shared_link/ui/shared_link_item.dart index e42a69b6f0..dfbf3e421b 100644 --- a/mobile/lib/modules/shared_link/ui/shared_link_item.dart +++ b/mobile/lib/modules/shared_link/ui/shared_link_item.dart @@ -76,8 +76,11 @@ class SharedLinkItem extends ConsumerWidget { final externalDomain = ref.read( serverInfoProvider.select((s) => s.serverConfig.externalDomain), ); - final serverUrl = + var serverUrl = externalDomain.isNotEmpty ? externalDomain : getServerUrl(); + if (serverUrl != null && !serverUrl.endsWith('/')) { + serverUrl += '/'; + } if (serverUrl == null) { ImmichToast.show( context: context, @@ -89,9 +92,7 @@ class SharedLinkItem extends ConsumerWidget { } Clipboard.setData( - ClipboardData( - text: "$serverUrl/share/${sharedLink.key}", - ), + ClipboardData(text: "${serverUrl}share/${sharedLink.key}"), ).then((_) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( diff --git a/mobile/lib/modules/shared_link/views/shared_link_edit_page.dart b/mobile/lib/modules/shared_link/views/shared_link_edit_page.dart index 7602a13233..87a2822dec 100644 --- a/mobile/lib/modules/shared_link/views/shared_link_edit_page.dart +++ b/mobile/lib/modules/shared_link/views/shared_link_edit_page.dart @@ -267,15 +267,7 @@ class SharedLinkEditPage extends HookConsumerWidget { } void copyLinkToClipboard() { - Clipboard.setData( - ClipboardData( - text: passwordController.text.isEmpty - ? newShareLink.value - : "shared_link_clipboard_text".tr( - args: [newShareLink.value, passwordController.text], - ), - ), - ).then((_) { + Clipboard.setData(ClipboardData(text: newShareLink.value)).then((_) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( @@ -358,10 +350,13 @@ class SharedLinkEditPage extends HookConsumerWidget { final externalDomain = ref.read( serverInfoProvider.select((s) => s.serverConfig.externalDomain), ); - final serverUrl = + var serverUrl = externalDomain.isNotEmpty ? externalDomain : getServerUrl(); + if (serverUrl != null && !serverUrl.endsWith('/')) { + serverUrl += '/'; + } if (newLink != null && serverUrl != null) { - newShareLink.value = "$serverUrl/share/${newLink.key}"; + newShareLink.value = "${serverUrl}share/${newLink.key}"; copyLinkToClipboard(); } else if (newLink == null) { ImmichToast.show(