Skip to content

Commit

Permalink
Merge pull request #92 from JunNishimura/#91
Browse files Browse the repository at this point in the history
limit the length of the album name
  • Loading branch information
JunNishimura authored Aug 31, 2023
2 parents 0144d8b + 94bfbdb commit 3e6fccd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions ui/cmd/hey/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,30 @@ func (s sessionState) String() string {
}
}

const albumMaxLen = 25

type album string

func (a album) String() string {
if len(a) > albumMaxLen {
return string(a)[:albumMaxLen]
}
return string(a)
}

type Item struct {
album string
album album
artists []string
uri spotify.URI
}

func (i Item) Title() string {
return lipgloss.NewStyle().
Foreground(lipgloss.Color(style.White)).
Render(i.album)
Render(i.album.String())
}
func (i Item) Description() string { return strings.Join(i.artists, ", ") }
func (i Item) FilterValue() string { return i.album }
func (i Item) FilterValue() string { return i.album.String() }

type Model struct {
ctx context.Context
Expand Down
2 changes: 1 addition & 1 deletion ui/cmd/hey/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (m *Model) recommend() tea.Msg {
}

item := Item{
album: track.Album.Name,
album: album(track.Album.Name),
artists: artists,
uri: track.URI,
}
Expand Down

0 comments on commit 3e6fccd

Please sign in to comment.