feat: BIG changes

* use commands constants
* use a separate goroutine to read from connection
* refactor connection reading and ui updating
* add sidepanel for users in channel
* other cleanups
This commit is contained in:
2022-01-09 04:30:22 +02:00
parent 1168a2a4dd
commit 8a7e1568ae
11 changed files with 280 additions and 97 deletions
+9 -7
View File
@@ -29,17 +29,15 @@ type InputState struct {
Client *client.Client
}
func NewInputBox(client *client.Client) InputState {
func NewInputBox() InputState {
input := textinput.NewModel()
input.Placeholder = "Send a message..."
input.Focus()
state := InputState{
Input: input,
Style: InputboxStyle.Copy(),
Client: client,
}
return state
return InputState{
Input: input,
Style: InputboxStyle.Copy(),
}
}
func (s InputState) Update(msg tea.Msg) (InputState, tea.Cmd) {
@@ -49,6 +47,10 @@ func (s InputState) Update(msg tea.Msg) (InputState, tea.Cmd) {
switch key {
case "enter":
value := s.Input.Value()
if len(value) == 0 {
return s, nil
}
s.Input.Reset()
return s, s.SendingPrivMsg(value)