Don't set a note if the note didn't actually change

This commit is contained in:
Christian Rocha 2020-05-20 16:27:19 -04:00 committed by Christian Muehlhaeuser
commit 1219d22834

View file

@ -120,10 +120,14 @@ func pagerUpdate(msg boba.Msg, m pagerModel) (pagerModel, boba.Cmd) {
m.state = pagerStateBrowse
return m, nil
case "enter":
m.currentDocument.Note = m.textInput.Value() // update optimistically
var cmd boba.Cmd
if m.textInput.Value() != m.currentDocument.Note { // don't update if the note didn't change
m.currentDocument.Note = m.textInput.Value() // update optimistically
cmd = saveDocumentNote(m.cc, m.currentDocument.ID, m.currentDocument.Note)
}
m.state = pagerStateBrowse
m.textInput.Reset()
return m, saveDocumentNote(m.cc, m.currentDocument.ID, m.currentDocument.Note)
return m, cmd
}
default:
switch msg.String() {