diff --git a/Makefile b/Makefile index 16b5f67..052b42d 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,14 @@ build-all: test: go test ./... +lint: + golangci-lint run + +check: lint test build + goreleaser check + clean: go clean rm -f $(BINARY_NAME) $(BINARY_NAME)-* -.PHONY: build build-all test clean \ No newline at end of file +.PHONY: build build-all test lint check clean \ No newline at end of file diff --git a/go.mod b/go.mod index 2627622..b826b9f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/glebovdev/somafm-cli go 1.24.0 require ( - github.com/gdamore/tcell/v2 v2.13.5 + github.com/gdamore/tcell/v2 v2.13.6 github.com/go-resty/resty/v2 v2.17.1 github.com/gopxl/beep/v2 v2.1.1 github.com/rivo/tview v0.42.0 @@ -22,7 +22,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect golang.org/x/net v0.48.0 // indirect - golang.org/x/sys v0.39.0 // indirect + golang.org/x/sys v0.40.0 // indirect golang.org/x/term v0.38.0 // indirect golang.org/x/text v0.32.0 // indirect ) diff --git a/go.sum b/go.sum index 79c0e05..6dcfe39 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/ebitengine/purego v0.9.1 h1:a/k2f2HQU3Pi399RPW1MOaZyhKJL9w/xFpKAg4q1s github.com/ebitengine/purego v0.9.1/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= -github.com/gdamore/tcell/v2 v2.13.5 h1:YvWYCSr6gr2Ovs84dXbZLjDuOfQchhj8buOEqY52rpA= -github.com/gdamore/tcell/v2 v2.13.5/go.mod h1:+Wfe208WDdB7INEtCsNrAN6O2m+wsTPk1RAovjaILlo= +github.com/gdamore/tcell/v2 v2.13.6 h1:ZAKaC+z7EHtDlELEVw5qxvO560cCXOtn0Su4YqMahJM= +github.com/gdamore/tcell/v2 v2.13.6/go.mod h1:+Wfe208WDdB7INEtCsNrAN6O2m+wsTPk1RAovjaILlo= github.com/go-resty/resty/v2 v2.17.1 h1:x3aMpHK1YM9e4va/TMDRlusDDoZiQ+ViDu/WpA6xTM4= github.com/go-resty/resty/v2 v2.17.1/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -63,8 +63,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= -golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= diff --git a/internal/ui/ui.go b/internal/ui/ui.go index a469ea0..b06ff65 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -179,22 +179,33 @@ func (ui *UI) Shutdown() { func (ui *UI) Run() error { ui.setupLoadingScreen() ui.app.SetRoot(ui.loadingScreen, true) + ui.configureScreen() + go ui.initAsync() + + return ui.app.Run() +} + +func (ui *UI) configureScreen() { + bgStyle := tcell.StyleDefault.Background(ui.colors.background) ui.app.SetBeforeDrawFunc(func(screen tcell.Screen) bool { - screen.SetStyle(tcell.StyleDefault.Background(ui.colors.background)) + screen.SetStyle(bgStyle) screen.Clear() return false }) - go func() { - if err := ui.fetchStationsAndInitUI(); err != nil { - ui.app.QueueUpdateDraw(func() { - ui.handleInitialError(err) - }) - } - }() + var titleSet sync.Once + ui.app.SetAfterDrawFunc(func(screen tcell.Screen) { + titleSet.Do(func() { screen.SetTitle(config.AppName) }) + }) +} - return ui.app.Run() +func (ui *UI) initAsync() { + if err := ui.fetchStationsAndInitUI(); err != nil { + ui.app.QueueUpdateDraw(func() { + ui.handleInitialError(err) + }) + } } func (ui *UI) setupLoadingScreen() {