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
main
Timon 2026-06-04 00:19:35 +02:00 committed by GitHub
parent 5c33eb3204
commit d21cb28526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 21 deletions

View File

@ -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<String?>.absent();
var description = const Optional<String?>.absent();
String? slug;
DateTime? expiry;
bool? changeExpiry;
var expiry = const Optional<DateTime?>.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;

View File

@ -88,11 +88,10 @@ class SharedLinkService {
required bool? showMeta,
required bool? allowDownload,
required bool? allowUpload,
bool? changeExpiry = false,
String? description,
String? password,
Optional<String?> password = const Optional.absent(),
Optional<String?> description = const Optional.absent(),
String? slug,
DateTime? expiresAt,
Optional<DateTime?> 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) {