Skip to content

Commit

Permalink
[MOBILE-3571] Send up an empty form response (#2705)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski authored Mar 23, 2023
1 parent 2ab8a30 commit e58229b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
5 changes: 1 addition & 4 deletions Airship/AirshipCore/Source/FormState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public struct FormInputData {
guard let value = value else {
return nil
}

return [
FormInputData.typeKey: "text_input",
FormInputData.valueKey: value
Expand All @@ -211,10 +212,6 @@ public struct FormInputData {
childrenMap[value.identifier] = value.getData()
}

guard !childrenMap.isEmpty else {
return nil
}

switch formType {
case .form:
return [
Expand Down
19 changes: 9 additions & 10 deletions Airship/AirshipCore/Source/ThomasEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class ThomasEnvironment : ObservableObject {
return
}

if let formResult = formState.toFormResult() {
self.delegate.onFormSubmitted(formResult: formResult,
layoutContext: layoutState.toLayoutContext())
}
self.delegate.onFormSubmitted(
formResult: formState.toFormResult(),
layoutContext: layoutState.toLayoutContext()
)

let channelEditor = Airship.channel.editAttributes()
let contactEditor = Airship.contact.editAttributes()
Expand Down Expand Up @@ -209,12 +209,11 @@ private extension FormState {
}
}

func toFormResult() -> ThomasFormResult? {
if let data = self.data.toPayload() {
return ThomasFormResult(identifier: self.identifier,
formData: data)
}
return nil
func toFormResult() -> ThomasFormResult {
return ThomasFormResult(
identifier: self.identifier,
formData: self.data.toPayload() ?? [:]
)
}
}

Expand Down

0 comments on commit e58229b

Please sign in to comment.