Skip to content

Commit

Permalink
Avoid defaults overriding values from form
Browse files Browse the repository at this point in the history
Fixes ignored MsgTo, MsgBcc and other common fields.
  • Loading branch information
martinhpedersen committed Dec 29, 2023
1 parent 87f28ba commit d4d06ae
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions internal/forms/forms.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,14 +983,20 @@ func (b formMessageBuilder) initFormValues() {
b.FormValues["msgsender"] = b.FormsMgr.config.MyCall

// some defaults that we can't set yet. Winlink doesn't seem to care about these
b.FormValues["msgto"] = ""
b.FormValues["msgcc"] = ""
b.FormValues["msgsubject"] = ""
b.FormValues["msgbody"] = ""
b.FormValues["msgp2p"] = ""
b.FormValues["msgisforward"] = "False"
b.FormValues["msgisacknowledgement"] = "False"
b.FormValues["msgseqnum"] = "0"
// Set only if they're not set by form values.
for _, key := range []string{"msgto", "msgcc", "msgsubject", "msgbody", "msgp2p"} {
if _, ok := b.FormValues[key]; !ok {
b.FormValues[key] = ""
}
}
for _, key := range []string{"msgisforward", "msgisacknowledgement"} {
if _, ok := b.FormValues[key]; !ok {
b.FormValues[key] = "False"
}
}
if _, ok := b.FormValues["msgseqnum"]; !ok {
b.FormValues["msgseqnum"] = "0"
}
}

func (b formMessageBuilder) scanTmplBuildMessage(tmplPath string) (MessageForm, error) {
Expand Down Expand Up @@ -1046,6 +1052,8 @@ func (b formMessageBuilder) scanTmplBuildMessage(tmplPath string) (MessageForm,
msgForm.To = strings.TrimSpace(value)
case "Cc":
msgForm.Cc = strings.TrimSpace(value)
case "Readonly":
// TODO: Disable editing of body in composer?
default:
if inBody {
msgForm.Body += lineTmpl + "\n"
Expand Down

0 comments on commit d4d06ae

Please sign in to comment.