Skip to content

Commit

Permalink
chore: Delete cache playlists when playlists are modified
Browse files Browse the repository at this point in the history
  • Loading branch information
natilou committed May 2, 2024
1 parent 560f982 commit e925b2f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions backend/mediaprovider/subsonic/subsonicmediaprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"image"
"io"
"log"

Check failure on line 7 in backend/mediaprovider/subsonic/subsonicmediaprovider.go

View workflow job for this annotation

GitHub Actions / build

"log" imported and not used

Check failure on line 7 in backend/mediaprovider/subsonic/subsonicmediaprovider.go

View workflow job for this annotation

GitHub Actions / build

"log" imported and not used

Check failure on line 7 in backend/mediaprovider/subsonic/subsonicmediaprovider.go

View workflow job for this annotation

GitHub Actions / build

"log" imported and not used
"math"
"net/url"
"slices"
Expand Down Expand Up @@ -39,10 +40,12 @@ func (s *subsonicMediaProvider) SetPrefetchCoverCallback(cb func(coverArtID stri
}

func (s *subsonicMediaProvider) CreatePlaylist(name string, trackIDs []string) error {
s.playlistsCached = nil
return s.client.CreatePlaylistWithTracks(trackIDs, map[string]string{"name": name})
}

func (s *subsonicMediaProvider) DeletePlaylist(id string) error {
s.playlistsCached = nil
return s.client.DeletePlaylist(id)
}

Expand All @@ -51,6 +54,7 @@ func (s *subsonicMediaProvider) CanMakePublicPlaylist() bool {
}

func (s *subsonicMediaProvider) EditPlaylist(id, name, description string, public bool) error {
s.playlistsCached = nil
return s.client.UpdatePlaylist(id, map[string]string{
"name": name,
"comment": description,
Expand All @@ -59,10 +63,12 @@ func (s *subsonicMediaProvider) EditPlaylist(id, name, description string, publi
}

func (s *subsonicMediaProvider) AddPlaylistTracks(id string, trackIDsToAdd []string) error {
s.playlistsCached = nil
return s.client.UpdatePlaylistTracks(id, trackIDsToAdd, nil)
}

func (s *subsonicMediaProvider) RemovePlaylistTracks(id string, removeIdxs []int) error {
s.playlistsCached = nil
return s.client.UpdatePlaylistTracks(id, nil, removeIdxs)
}

Expand Down Expand Up @@ -242,6 +248,7 @@ func (s *subsonicMediaProvider) GetTopTracks(artist mediaprovider.Artist, count
}

func (s *subsonicMediaProvider) ReplacePlaylistTracks(playlistID string, trackIDs []string) error {
s.playlistsCached = nil
return s.client.CreatePlaylistWithTracks(trackIDs, map[string]string{"playlistId": playlistID})
}

Expand Down

0 comments on commit e925b2f

Please sign in to comment.