Fix actionSend to solve quick enter key presses

Fixes #16
This commit is contained in:
erroneousboat 2016-10-14 17:04:22 +02:00
parent 926a00f6ac
commit c0cb2040a0
2 changed files with 8 additions and 7 deletions

View File

@ -10,8 +10,6 @@ import (
type Input struct {
Par *termui.Par
CursorPosition int
CursorFgColor termui.Attribute
CursorBgColor termui.Attribute
}
// CreateInput is the constructor of the Input struct
@ -19,8 +17,6 @@ func CreateInput() *Input {
input := &Input{
Par: termui.NewPar(""),
CursorPosition: 0,
CursorBgColor: termui.ColorBlack,
CursorFgColor: termui.ColorWhite,
}
input.Par.Height = 3

View File

@ -147,13 +147,18 @@ func actionMoveCursorLeft(view *views.View) {
func actionSend(ctx *context.AppContext) {
if !ctx.View.Input.IsEmpty() {
// Clear message before sending, to combat
// quick succession of actionSend
message := ctx.View.Input.Text()
ctx.View.Input.Clear()
ctx.View.Refresh()
ctx.View.Input.SendMessage(
ctx.Service,
ctx.Service.Channels[ctx.View.Channels.SelectedChannel].ID,
ctx.View.Input.Text(),
message,
)
ctx.View.Input.Clear()
ctx.View.Refresh()
}
}