diff --git a/internal/app/chat_view.go b/internal/app/chat_view.go index ee7def4..3cfbf24 100644 --- a/internal/app/chat_view.go +++ b/internal/app/chat_view.go @@ -11,7 +11,6 @@ import ( type chatView struct { composing string inFocus bool - history []sim.ChatMessage } func (c *chatView) handleEvent(e tcell.Event) change { @@ -51,8 +50,8 @@ func (c *chatView) draw(img canvas, st *state) { bounds := img.bounds() fill(img, tcell.StyleDefault.Background(tcell.NewRGBColor(32, 32, 32))) chatHeight := bounds.Height - 1 - for i := 0; i < math.Min(chatHeight, len(c.history)); i++ { - msg := c.history[len(c.history)-1-i] + for i := 0; i < math.Min(chatHeight, len(st.history)); i++ { + msg := st.history[len(st.history)-1-i] s := fmt.Sprintf("%12s: %s", msg.From, msg.Text) writeString(img, s, math.Vec{0, bounds.Height - 2 - i}, tcell.StyleDefault) } diff --git a/internal/app/state.go b/internal/app/state.go index 158d745..6a19059 100644 --- a/internal/app/state.go +++ b/internal/app/state.go @@ -1,8 +1,12 @@ package app -import "github.com/jordanorelli/astro-domu/internal/wire" +import ( + "github.com/jordanorelli/astro-domu/internal/sim" + "github.com/jordanorelli/astro-domu/internal/wire" +) type state struct { playerName string room *wire.Room + history []sim.ChatMessage } diff --git a/internal/app/ui.go b/internal/app/ui.go index 45a9558..a439ffb 100644 --- a/internal/app/ui.go +++ b/internal/app/ui.go @@ -128,7 +128,7 @@ func (ui *UI) handleNotification(v wire.Value) bool { return true case *sim.ChatMessage: - // ui.chatView.history = append(ui.chatView.history, *n) + ui.state.history = append(ui.state.history, *n) return true default: