feat(quick-7): add PinDefault config field with backend getter/setter

- Add PinDefault bool to favorites.Config struct with TOML tag
- Add GetPinDefaultPlaylist() and SetPinDefaultPlaylist() methods
- Include PinDefault in emitFavoritesChanged event payload
- Default to true (pinned) for new config installations
This commit is contained in:
2026-03-01 10:05:22 -05:00
parent 0119cb469a
commit 6e123bd47f
2 changed files with 41 additions and 1 deletions
+40 -1
View File
@@ -184,7 +184,9 @@ func (c *Config) applyDefaults() {
c.TrackList.ApplyDefaults()
if c.Favorites == nil {
c.Favorites = &favorites.Config{}
c.Favorites = &favorites.Config{
PinDefault: true,
}
}
c.Favorites.ApplyDefaults()
@@ -527,6 +529,42 @@ func (c *Config) SetFavoritesIconStyle(
return nil
}
// GetPinDefaultPlaylist returns whether the default playlist
// is pinned to the top of the playlist view.
func (c *Config) GetPinDefaultPlaylist() bool {
if c.Favorites == nil {
return true // default: pinned
}
return c.Favorites.PinDefault
}
// SetPinDefaultPlaylist saves whether the default playlist
// should be pinned to the top of the playlist view.
func (c *Config) SetPinDefaultPlaylist(pin bool) error {
if c.Favorites == nil {
c.Favorites = &favorites.Config{}
c.Favorites.ApplyDefaults()
}
c.Favorites.PinDefault = pin
if err := c.Save(); err != nil {
return fmt.Errorf(
"could not save config: %w", err,
)
}
c.emitFavoritesChanged()
c.logger.Info(
"pin default playlist updated",
"pin", pin,
)
return nil
}
// emitFavoritesChanged sends the FavoritesConfigChanged event
// to the frontend.
func (c *Config) emitFavoritesChanged() {
@@ -540,6 +578,7 @@ func (c *Config) emitFavoritesChanged() {
map[string]any{
"PlaylistID": c.Favorites.PlaylistID,
"IconStyle": string(c.Favorites.IconStyle),
"PinDefault": c.Favorites.PinDefault,
},
)
}
+1
View File
@@ -33,6 +33,7 @@ const DefaultPlaylistName = "Favorites"
type Config struct {
PlaylistID int64 `toml:"PlaylistID"`
IconStyle IconStyle `toml:"IconStyle"`
PinDefault bool `toml:"PinDefault"`
}
// ApplyDefaults fills zero-value fields with sensible defaults.