fix: profile field edit update logic issue

This commit is contained in:
CMK 2021-05-31 16:57:48 +08:00
parent 26b48957cd
commit 3ed43a3575
2 changed files with 9 additions and 4 deletions

View File

@ -30,7 +30,6 @@ final class ProfileFieldView: UIView {
textField.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 20) textField.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold), maximumPointSize: 20)
textField.textColor = Asset.Colors.Label.primary.color textField.textColor = Asset.Colors.Label.primary.color
textField.placeholder = L10n.Scene.Profile.Fields.Placeholder.label textField.placeholder = L10n.Scene.Profile.Fields.Placeholder.label
textField.isEnabled = false
return textField return textField
}() }()

View File

@ -217,9 +217,15 @@ extension Mastodon.API.Account {
source.sensitive.flatMap { data.append(Data.multipart(key: "source[privacy]", value: $0)) } source.sensitive.flatMap { data.append(Data.multipart(key: "source[privacy]", value: $0)) }
source.language.flatMap { data.append(Data.multipart(key: "source[privacy]", value: $0)) } source.language.flatMap { data.append(Data.multipart(key: "source[privacy]", value: $0)) }
} }
for (i, fieldsAttribute) in (fieldsAttributes ?? []).enumerated() { if let fieldsAttributes = fieldsAttributes {
data.append(Data.multipart(key: "fields_attributes[\(i)][name]", value: fieldsAttribute.name)) if fieldsAttributes.isEmpty {
data.append(Data.multipart(key: "fields_attributes[\(i)][value]", value: fieldsAttribute.value)) data.append(Data.multipart(key: "fields_attributes[]", value: ""))
} else {
for (i, fieldsAttribute) in fieldsAttributes.enumerated() {
data.append(Data.multipart(key: "fields_attributes[\(i)][name]", value: fieldsAttribute.name))
data.append(Data.multipart(key: "fields_attributes[\(i)][value]", value: fieldsAttribute.value))
}
}
} }
data.append(Data.multipartEnd()) data.append(Data.multipartEnd())