From b4e24bf113548264aae6ea82b74b6cd0952b67b3 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Fri, 20 Dec 2024 18:35:09 -0500 Subject: [PATCH] feat: close websocket connection gracefully on quit --- cmd/layout.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/layout.go b/cmd/layout.go index ad29427..d77d30e 100644 --- a/cmd/layout.go +++ b/cmd/layout.go @@ -86,6 +86,10 @@ func (l *Layout) init() { func (l *Layout) onAppInputCapture(event *tcell.EventKey) *tcell.EventKey { switch event.Name() { case l.cfg.Keys.Quit: + if err := discordState.Close(); err != nil { + slog.Error("failed to close the session", "err", err) + } + l.app.Stop() case "Ctrl+C": // https://github.com/rivo/tview/blob/a64fc48d7654432f71922c8b908280cdb525805c/application.go#L153