Skip to content

Commit c41db9c

Browse files
committed
feat: remember some credential details for login tui view
1 parent 3826da8 commit c41db9c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/ui/tui/login.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/charmbracelet/bubbles/textinput"
88
tea "github.com/charmbracelet/bubbletea"
99
"github.com/charmbracelet/lipgloss"
10+
"github.com/j0h-dev/my-spotify-playlist-sorter-go/internal/config"
1011
"github.com/j0h-dev/my-spotify-playlist-sorter-go/internal/domain"
1112
"github.com/j0h-dev/my-spotify-playlist-sorter-go/internal/spotify"
1213
)
@@ -44,6 +45,7 @@ type LoginModel struct {
4445
}
4546

4647
func NewLoginModel() *LoginModel {
48+
4749
// initialize text inputs
4850
clientIdField := textinput.New()
4951
clientIdField.Placeholder = "client id"
@@ -61,6 +63,12 @@ func NewLoginModel() *LoginModel {
6163
clientRedirectField.Prompt = "Redirect URI: "
6264
clientRedirectField.Width = 80
6365

66+
conf := config.ReadConfig()
67+
if conf.Credentials != nil {
68+
clientIdField.SetValue(conf.Credentials.ClientID)
69+
clientRedirectField.SetValue(conf.Credentials.RedirectURI)
70+
}
71+
6472
loadingSpinner := spinner.New()
6573
loadingSpinner.Spinner = spinner.Dot
6674
loadingSpinner.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))

0 commit comments

Comments
 (0)