From d21cb285261737d7fd8a317f5a6ce4513f741102 Mon Sep 17 00:00:00 2001 From: Timon Date: Thu, 4 Jun 2026 00:19:35 +0200 Subject: [PATCH] fix(mobile): shared link edit sends explicit null instead of empty string (#28812) * fix(mobile): clear shared link password * fix(mobile): clear shared link description * fix(mobile): clear shared link expiry --- .../shared_link/shared_link_edit.page.dart | 28 ++++++++++--------- mobile/lib/services/shared_link.service.dart | 14 ++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mobile/lib/pages/library/shared_link/shared_link_edit.page.dart b/mobile/lib/pages/library/shared_link/shared_link_edit.page.dart index 41486d7c98..65973918e4 100644 --- a/mobile/lib/pages/library/shared_link/shared_link_edit.page.dart +++ b/mobile/lib/pages/library/shared_link/shared_link_edit.page.dart @@ -11,6 +11,7 @@ import 'package:immich_mobile/models/shared_link/shared_link.model.dart'; import 'package:immich_mobile/providers/server_info.provider.dart'; import 'package:immich_mobile/providers/shared_link.provider.dart'; import 'package:immich_mobile/services/shared_link.service.dart'; +import 'package:openapi/api.dart'; import 'package:immich_mobile/utils/url_helper.dart'; import 'package:immich_mobile/widgets/common/confirm_dialog.dart'; import 'package:immich_mobile/widgets/common/immich_toast.dart'; @@ -365,11 +366,10 @@ class SharedLinkEditPage extends HookConsumerWidget { bool? download; bool? upload; bool? meta; - String? desc; - String? password; + var password = const Optional.absent(); + var description = const Optional.absent(); String? slug; - DateTime? expiry; - bool? changeExpiry; + var expiry = const Optional.absent(); if (allowDownload.value != existingLink!.allowDownload) { download = allowDownload.value; @@ -383,12 +383,16 @@ class SharedLinkEditPage extends HookConsumerWidget { meta = showMetadata.value; } - if (descriptionController.text != existingLink!.description) { - desc = descriptionController.text; + if (descriptionController.text != (existingLink!.description ?? '')) { + description = descriptionController.text.isEmpty + ? const Optional.present(null) + : Optional.present(descriptionController.text); } - if (passwordController.text != existingLink!.password) { - password = passwordController.text; + if (passwordController.text != (existingLink!.password ?? '')) { + password = passwordController.text.isEmpty + ? const Optional.present(null) + : Optional.present(passwordController.text); } if (slugController.text != (existingLink!.slug ?? "")) { @@ -399,8 +403,7 @@ class SharedLinkEditPage extends HookConsumerWidget { final newExpiry = expiryAfter.value; if (newExpiry?.toUtc() != existingLink!.expiresAt?.toUtc()) { - expiry = newExpiry; - changeExpiry = true; + expiry = newExpiry == null ? const Optional.present(null) : Optional.present(newExpiry.toUtc()); } await ref @@ -410,11 +413,10 @@ class SharedLinkEditPage extends HookConsumerWidget { showMeta: meta, allowDownload: download, allowUpload: upload, - description: desc, + description: description, password: password, slug: slug, - expiresAt: expiry?.toUtc(), - changeExpiry: changeExpiry, + expiresAt: expiry, ); if (!context.mounted) { return; diff --git a/mobile/lib/services/shared_link.service.dart b/mobile/lib/services/shared_link.service.dart index 009e922b38..975070f2a0 100644 --- a/mobile/lib/services/shared_link.service.dart +++ b/mobile/lib/services/shared_link.service.dart @@ -88,11 +88,10 @@ class SharedLinkService { required bool? showMeta, required bool? allowDownload, required bool? allowUpload, - bool? changeExpiry = false, - String? description, - String? password, + Optional password = const Optional.absent(), + Optional description = const Optional.absent(), String? slug, - DateTime? expiresAt, + Optional expiresAt = const Optional.absent(), }) async { try { final responseDto = await _apiService.sharedLinksApi.updateSharedLink( @@ -101,11 +100,10 @@ class SharedLinkService { showMetadata: showMeta == null ? const Optional.absent() : Optional.present(showMeta), allowDownload: allowDownload == null ? const Optional.absent() : Optional.present(allowDownload), allowUpload: allowUpload == null ? const Optional.absent() : Optional.present(allowUpload), - expiresAt: expiresAt == null ? const Optional.absent() : Optional.present(expiresAt), - description: description == null ? const Optional.absent() : Optional.present(description), - password: password == null ? const Optional.absent() : Optional.present(password), + password: password, + description: description, + expiresAt: expiresAt, slug: slug == null ? const Optional.absent() : Optional.present(slug), - changeExpiryTime: changeExpiry == null ? const Optional.absent() : Optional.present(changeExpiry), ), ); if (responseDto != null) {