aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Garrelou <simon.garrelou@gmail.com>2022-12-11 20:54:33 +0100
committerSimon Garrelou <simon.garrelou@gmail.com>2022-12-11 20:54:33 +0100
commitc27a2911eff2ffaa50977f9365ae0736e3b76b8a (patch)
tree9898d8571c5593d63061516025c2f1991ed36f33
parentf4aa3110214513afbba43b2d1d483dc201d70e00 (diff)
downloadtermsonic-c27a2911eff2ffaa50977f9365ae0736e3b76b8a.tar.gz
termsonic-c27a2911eff2ffaa50977f9365ae0736e3b76b8a.zip
Add "Refresh" in config page
-rw-r--r--src/footer.go2
-rw-r--r--src/keybinds.go4
-rw-r--r--src/page_artists.go2
-rw-r--r--src/page_config.go20
-rw-r--r--src/page_playlists.go2
-rw-r--r--src/page_queue.go2
6 files changed, 26 insertions, 6 deletions
diff --git a/src/footer.go b/src/footer.go
index f75f954..77c732a 100644
--- a/src/footer.go
+++ b/src/footer.go
@@ -17,6 +17,6 @@ func (a *app) updateFooter() {
17 a.footer.SetText("[blue]l:[yellow] Next song [blue]p:[yellow] Toggle pause [blue]e:[yellow] Play song last [blue]n:[yellow] Play song next") 17 a.footer.SetText("[blue]l:[yellow] Next song [blue]p:[yellow] Toggle pause [blue]e:[yellow] Play song last [blue]n:[yellow] Play song next")
18 } 18 }
19 case "config": 19 case "config":
20 a.footer.SetText("[yellow]No shortcuts here") 20 a.footer.SetText("[blue]R:[yellow] Refresh")
21 } 21 }
22} 22}
diff --git a/src/keybinds.go b/src/keybinds.go
index e3b80a1..f9d932c 100644
--- a/src/keybinds.go
+++ b/src/keybinds.go
@@ -5,9 +5,9 @@ import (
5 "github.com/rivo/tview" 5 "github.com/rivo/tview"
6) 6)
7 7
8func (a *app) setupMusicControlKeys(p *tview.Box) { 8func (a *app) setupKeybindings(p *tview.Box) {
9 // Add 'k' and 'l' key bindings
10 p.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { 9 p.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
10 // Next & pause
11 if event.Rune() == 'l' { 11 if event.Rune() == 'l' {
12 a.playQueue.Next() 12 a.playQueue.Next()
13 return nil 13 return nil
diff --git a/src/page_artists.go b/src/page_artists.go
index e0c13fd..4175f3c 100644
--- a/src/page_artists.go
+++ b/src/page_artists.go
@@ -62,7 +62,7 @@ func (a *app) artistsPage() tview.Primitive {
62 return event 62 return event
63 }) 63 })
64 64
65 a.setupMusicControlKeys(grid.Box) 65 a.setupKeybindings(grid.Box)
66 66
67 grid.AddItem(a.artistsTree, 0, 1, true) 67 grid.AddItem(a.artistsTree, 0, 1, true)
68 grid.AddItem(a.songsList, 0, 1, false) 68 grid.AddItem(a.songsList, 0, 1, false)
diff --git a/src/page_config.go b/src/page_config.go
index 71662ec..2f8a27b 100644
--- a/src/page_config.go
+++ b/src/page_config.go
@@ -5,6 +5,7 @@ import (
5 "net/http" 5 "net/http"
6 6
7 "github.com/delucks/go-subsonic" 7 "github.com/delucks/go-subsonic"
8 "github.com/gdamore/tcell/v2"
8 "github.com/rivo/tview" 9 "github.com/rivo/tview"
9) 10)
10 11
@@ -36,6 +37,25 @@ func (a *app) configPage() *tview.Form {
36 a.alert("All good!") 37 a.alert("All good!")
37 } 38 }
38 }) 39 })
40
41 form.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
42 if event.Rune() == 'R' {
43 if err := a.refreshArtists(); err != nil {
44 a.alert("Error: %v", err)
45 return nil
46 }
47
48 if err := a.refreshPlaylists(); err != nil {
49 a.alert("Error: %v", err)
50 return nil
51 }
52
53 a.alert("Refreshed successfully")
54 }
55
56 return nil
57 })
58
39 return form 59 return form
40} 60}
41 61
diff --git a/src/page_playlists.go b/src/page_playlists.go
index 303a9a7..2ec8165 100644
--- a/src/page_playlists.go
+++ b/src/page_playlists.go
@@ -40,7 +40,7 @@ func (a *app) playlistsPage() tview.Primitive {
40 }) 40 })
41 41
42 // Setup e & n keybinds 42 // Setup e & n keybinds
43 a.setupMusicControlKeys(flex.Box) 43 a.setupKeybindings(flex.Box)
44 44
45 flex.AddItem(a.playlistsList, 0, 1, false) 45 flex.AddItem(a.playlistsList, 0, 1, false)
46 flex.AddItem(a.playlistSongs, 0, 1, false) 46 flex.AddItem(a.playlistSongs, 0, 1, false)
diff --git a/src/page_queue.go b/src/page_queue.go
index fe8910f..5912656 100644
--- a/src/page_queue.go
+++ b/src/page_queue.go
@@ -11,7 +11,7 @@ func (a *app) queuePage() tview.Primitive {
11 ShowSecondaryText(false). 11 ShowSecondaryText(false).
12 SetHighlightFullLine(true) 12 SetHighlightFullLine(true)
13 13
14 a.setupMusicControlKeys(a.playQueueList.Box) 14 a.setupKeybindings(a.playQueueList.Box)
15 15
16 a.updatePageQueue() 16 a.updatePageQueue()
17 17