Fix editing same message many times. Fixes #195

This commit is contained in:
Tulir Asokan 2020-08-31 01:28:39 +03:00
parent d9407ee8ee
commit db4aa77afa

View File

@ -436,8 +436,13 @@ func (view *RoomView) SetEditing(evt *muksevt.Event) {
view.editing = evt view.editing = evt
// replying should never be non-nil when SetEditing, but do this just to be safe // replying should never be non-nil when SetEditing, but do this just to be safe
view.replying = nil view.replying = nil
text := view.editing.Content.AsMessage().Body msgContent := view.editing.Content.AsMessage()
if view.editing.Content.AsMessage().MsgType == event.MsgEmote { if len(view.editing.Gomuks.Edits) > 0 {
// This feels kind of dangerous, but I think it works
msgContent = view.editing.Gomuks.Edits[len(view.editing.Gomuks.Edits)-1].Content.AsMessage().NewContent
}
text := msgContent.Body
if msgContent.MsgType == event.MsgEmote {
text = "/me " + text text = "/me " + text
} }
view.input.SetText(text) view.input.SetText(text)