From d66fac308881f253e772af61598754d5916fc92a Mon Sep 17 00:00:00 2001 From: jjohnstondev Date: Sat, 14 Jan 2023 20:59:52 -0800 Subject: [PATCH] volume and position tui dont get rate limited --- src/tui/handlers.go | 18 ++++++++++++++++++ src/tui/main.go | 12 ++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/tui/handlers.go b/src/tui/handlers.go index db419e2..6b483de 100644 --- a/src/tui/handlers.go +++ b/src/tui/handlers.go @@ -31,6 +31,24 @@ func HandleAlbumRadio(ctx *gctx.Context, client *spotify.Client, id spotify.ID) } } +func HandleSeek(ctx *gctx.Context, client *spotify.Client, fwd bool) { + err := commands.Seek(ctx, client, fwd) + if err != nil { + return + } +} + +func HandleVolume(ctx *gctx.Context, client *spotify.Client, up bool) { + vol := 10 + if !up { + vol = -10 + } + err := commands.ChangeVolume(ctx, client, vol) + if err != nil { + return + } +} + func HandleArtistRadio(ctx *gctx.Context, client *spotify.Client, id spotify.ID) { err := commands.RadioGivenArtist(ctx, client, id) if err != nil { diff --git a/src/tui/main.go b/src/tui/main.go index ac57811..2c2eaac 100644 --- a/src/tui/main.go +++ b/src/tui/main.go @@ -457,6 +457,18 @@ func (m mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg.String() == "ctrl+c" { return m, tea.Quit } + if msg.String() == ">" { + go HandleSeek(m.ctx, m.client, true) + } + if msg.String() == "<" { + go HandleSeek(m.ctx, m.client, false) + } + if msg.String() == "+" { + go HandleVolume(m.ctx, m.client, true) + } + if msg.String() == "-" { + go HandleVolume(m.ctx, m.client, false) + } // search input if m.input.Focused() { search, cmd := m.Typing(msg)