diff options
Diffstat (limited to 'internal/client/ui/core/core.go')
| -rw-r--r-- | internal/client/ui/core/core.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index 4aa5d5d..1ba0069 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -1,6 +1,7 @@ package core import ( + "context" "crypto/ed25519" "fmt" "log" @@ -258,6 +259,19 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { switch msg := msg.(type) { case ui.QuitMsg: + data := state.JsonUserData() + ch := gateway.SendAsync(&packet.SetUserData{ + Data: &data, + User: nil, + }) + + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + select { + case <-ctx.Done(): + case <-ch: + } + cancel() + gateway.Disconnect() case gateway.ConnectionLost: |
