diff options
| author | Christian Cleberg <[email protected]> | 2026-07-15 19:25:27 -0500 |
|---|---|---|
| committer | Christian Cleberg <[email protected]> | 2026-07-15 19:25:27 -0500 |
| commit | 7ffef07278e94bd3c268ee5cbd5c9c11cbfa3270 (patch) | |
| tree | 7cec3dc403138d905694b0a74aa17498508de085 /Hutch/Views/Repositories | |
| parent | 63d0491b161457913c938d620dc1f26f29c798a9 (diff) | |
| download | hutch-7ffef07278e94bd3c268ee5cbd5c9c11cbfa3270.tar.gz hutch-7ffef07278e94bd3c268ee5cbd5c9c11cbfa3270.tar.bz2 hutch-7ffef07278e94bd3c268ee5cbd5c9c11cbfa3270.zip | |
fix: allow clearing a repository description
metadataInputForSave assigned nil through the dictionary subscript to clear a
description. Swift removes the key on a nil subscript assignment, so the
mutation was sent with no `description` field and the old value survived —
clearing a description silently did nothing.
Store the nil with updateValue so the key is retained; AnyCodable already
encodes an unmatched value as a JSON null.
Diffstat (limited to 'Hutch/Views/Repositories')
| -rw-r--r-- | Hutch/Views/Repositories/RepositorySettingsViewModel.swift | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Hutch/Views/Repositories/RepositorySettingsViewModel.swift b/Hutch/Views/Repositories/RepositorySettingsViewModel.swift index 6ad6a78..dd8d7a1 100644 --- a/Hutch/Views/Repositories/RepositorySettingsViewModel.swift +++ b/Hutch/Views/Repositories/RepositorySettingsViewModel.swift @@ -301,7 +301,14 @@ final class RepositorySettingsViewModel { } if normalizedEditedDescription != (repository.description ?? "") { - input["description"] = normalizedEditedDescription.isEmpty ? Optional<String>.none as String? : normalizedEditedDescription + if normalizedEditedDescription.isEmpty { + // Assigning nil through the subscript would remove the key and omit + // `description` from the mutation, leaving the old value in place. + // updateValue stores an explicit nil, which AnyCodable encodes as null. + input.updateValue(Optional<String>.none as any Sendable, forKey: "description") + } else { + input["description"] = normalizedEditedDescription + } } return input |
