mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
refactor: move getShareUrlPath to SharedLink class
This commit is contained in:
parent
e9fe6941d5
commit
71f6fe9f27
4 changed files with 8 additions and 12 deletions
|
|
@ -81,6 +81,11 @@ class SharedLink {
|
|||
? dto.assets[0].id
|
||||
: null;
|
||||
|
||||
String getShareUrlPath() {
|
||||
final slug = this.slug?.trim();
|
||||
return slug?.isNotEmpty == true ? 's/$slug' : 'share/$key';
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() =>
|
||||
'SharedLink(id=$id, title=$title, thumbAssetId=$thumbAssetId, allowDownload=$allowDownload, allowUpload=$allowUpload, description=$description, password=$password, expiresAt=$expiresAt, key=$key, showMetadata=$showMetadata, slug=$slug, type=$type)';
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ class SharedLinkEditPage extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
if (newLink != null && serverUrl != null) {
|
||||
final fullPath = getShareUrlPath(newLink);
|
||||
final fullPath = newLink.getShareUrlPath();
|
||||
newShareLink.value = "$serverUrl$fullPath";
|
||||
copyLinkToClipboard();
|
||||
} else if (newLink == null) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:immich_mobile/domain/models/store.model.dart';
|
||||
import 'package:immich_mobile/entities/store.entity.dart';
|
||||
import 'package:immich_mobile/models/shared_link/shared_link.model.dart';
|
||||
import 'package:punycode/punycode.dart';
|
||||
|
||||
String sanitizeUrl(String url) {
|
||||
|
|
@ -92,12 +91,4 @@ String? punycodeDecodeUrl(String? serverUrl) {
|
|||
return Uri.decodeFull(serverUri.replace(host: decodedHost).toString());
|
||||
}
|
||||
|
||||
/// Generates the appropriate share URL path for a given shared link.
|
||||
///
|
||||
/// Returns a path string based on the shared link's slug and key:
|
||||
/// - If slug is present: 's/${sharedLink.slug}'
|
||||
/// - Otherwise: 'share/${sharedLink.key}'
|
||||
String getShareUrlPath(SharedLink sharedLink) {
|
||||
final slug = sharedLink.slug?.trim();
|
||||
return slug?.isNotEmpty == true ? 's/$slug' : 'share/${sharedLink.key}';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class SharedLinkItem extends ConsumerWidget {
|
|||
return;
|
||||
}
|
||||
|
||||
final fullPath = getShareUrlPath(sharedLink);
|
||||
final fullPath = sharedLink.getShareUrlPath();
|
||||
|
||||
Clipboard.setData(ClipboardData(text: "$serverUrl$fullPath")).then((_) {
|
||||
context.scaffoldMessenger.showSnackBar(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue