Skip to content

Commit

Permalink
use correct message for parsed info in DisplayMessageFrame in mail
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Oct 2, 2024
1 parent 1d9a3ed commit 620c9a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mail/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (lb *Label) UIDSet() imap.UIDSet {

// ToDisplay converts the [CacheMessage] to a [displayMessage]
// with the given additional [readMessageParsed] data.
func (cm *CacheMessage) ToDisplay(rmp *readMessageParsed) *displayMessage {
func (cm *CacheMessage) ToDisplay() *displayMessage {
if cm == nil {
return nil
}
Expand All @@ -77,7 +77,7 @@ func (cm *CacheMessage) ToDisplay(rmp *readMessageParsed) *displayMessage {
To: IMAPToMailAddresses(cm.To),
Subject: cm.Subject,
Date: cm.Date.Local(),
Attachments: rmp.attachments,
Attachments: cm.parsed.attachments,
}
}

Expand Down
12 changes: 6 additions & 6 deletions mail/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (dmf *DisplayMessageFrame) Init() {
tree.AddChild(dmf, func(w *core.Form) {
w.SetReadOnly(true)
w.Updater(func() {
w.SetStruct(dmf.Message.ToDisplay(&theApp.readMessage.parsed))
w.SetStruct(dmf.Message.ToDisplay())
})
})
tree.AddChild(dmf, func(w *core.Frame) {
Expand Down Expand Up @@ -111,9 +111,9 @@ func (dmf *DisplayMessageFrame) displayMessageContents(w *core.Frame) error {
if err != nil {
return err
}
theApp.readMessage.parsed.references = refs
dmf.Message.parsed.references = refs

theApp.readMessage.parsed.attachments = nil
dmf.Message.parsed.attachments = nil
gotHTML := false
for {
p, err := mr.NextPart()
Expand All @@ -136,7 +136,7 @@ func (dmf *DisplayMessageFrame) displayMessageContents(w *core.Frame) error {
if err != nil {
return err
}
theApp.readMessage.parsed.plain = string(b)
dmf.Message.parsed.plain = string(b)
case "text/html":
err := htmlcore.ReadHTML(htmlcore.NewContext(), w, p.Body)
if err != nil {
Expand All @@ -154,13 +154,13 @@ func (dmf *DisplayMessageFrame) displayMessageContents(w *core.Frame) error {
if err != nil {
return err
}
theApp.readMessage.parsed.attachments = append(theApp.readMessage.parsed.attachments, at)
dmf.Message.parsed.attachments = append(dmf.Message.parsed.attachments, at)
}
}

// we only handle the plain version if there is no HTML version
if !gotHTML {
err := htmlcore.ReadMDString(htmlcore.NewContext(), w, theApp.readMessage.parsed.plain)
err := htmlcore.ReadMDString(htmlcore.NewContext(), w, dmf.Message.parsed.plain)
if err != nil {
return err
}
Expand Down

0 comments on commit 620c9a7

Please sign in to comment.