1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

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>
This commit is contained in:
shenlong 2024-01-10 15:32:09 +00:00 committed by GitHub
parent 0e0a472de1
commit 4f942bc182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 16 deletions

View File

@ -378,7 +378,6 @@
"share_dialog_preparing": "Preparing...", "share_dialog_preparing": "Preparing...",
"shared_link_app_bar_title": "Shared Links", "shared_link_app_bar_title": "Shared Links",
"shared_link_clipboard_copied_massage": "Copied to clipboard", "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_app_bar_title": "Create link to share",
"shared_link_create_error": "Error while creating shared link", "shared_link_create_error": "Error while creating shared link",
"shared_link_create_info": "Let anyone with the link see the selected photo(s)", "shared_link_create_info": "Let anyone with the link see the selected photo(s)",

View File

@ -76,8 +76,11 @@ class SharedLinkItem extends ConsumerWidget {
final externalDomain = ref.read( final externalDomain = ref.read(
serverInfoProvider.select((s) => s.serverConfig.externalDomain), serverInfoProvider.select((s) => s.serverConfig.externalDomain),
); );
final serverUrl = var serverUrl =
externalDomain.isNotEmpty ? externalDomain : getServerUrl(); externalDomain.isNotEmpty ? externalDomain : getServerUrl();
if (serverUrl != null && !serverUrl.endsWith('/')) {
serverUrl += '/';
}
if (serverUrl == null) { if (serverUrl == null) {
ImmichToast.show( ImmichToast.show(
context: context, context: context,
@ -89,9 +92,7 @@ class SharedLinkItem extends ConsumerWidget {
} }
Clipboard.setData( Clipboard.setData(
ClipboardData( ClipboardData(text: "${serverUrl}share/${sharedLink.key}"),
text: "$serverUrl/share/${sharedLink.key}",
),
).then((_) { ).then((_) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(

View File

@ -267,15 +267,7 @@ class SharedLinkEditPage extends HookConsumerWidget {
} }
void copyLinkToClipboard() { void copyLinkToClipboard() {
Clipboard.setData( Clipboard.setData(ClipboardData(text: newShareLink.value)).then((_) {
ClipboardData(
text: passwordController.text.isEmpty
? newShareLink.value
: "shared_link_clipboard_text".tr(
args: [newShareLink.value, passwordController.text],
),
),
).then((_) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text( content: Text(
@ -358,10 +350,13 @@ class SharedLinkEditPage extends HookConsumerWidget {
final externalDomain = ref.read( final externalDomain = ref.read(
serverInfoProvider.select((s) => s.serverConfig.externalDomain), serverInfoProvider.select((s) => s.serverConfig.externalDomain),
); );
final serverUrl = var serverUrl =
externalDomain.isNotEmpty ? externalDomain : getServerUrl(); externalDomain.isNotEmpty ? externalDomain : getServerUrl();
if (serverUrl != null && !serverUrl.endsWith('/')) {
serverUrl += '/';
}
if (newLink != null && serverUrl != null) { if (newLink != null && serverUrl != null) {
newShareLink.value = "$serverUrl/share/${newLink.key}"; newShareLink.value = "${serverUrl}share/${newLink.key}";
copyLinkToClipboard(); copyLinkToClipboard();
} else if (newLink == null) { } else if (newLink == null) {
ImmichToast.show( ImmichToast.show(