Only refresh smart playlist when fetching first track (#3244)

* Only refresh smart playlist when fetching first track

* res -> w
This commit is contained in:
Kendall Garner 2024-09-11 00:18:37 +00:00 committed by GitHub
parent e1762882e3
commit 9f1794b97e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,14 +22,16 @@ type restHandler = func(rest.RepositoryConstructor, ...rest.Logger) http.Handler
func getPlaylist(ds model.DataStore) http.HandlerFunc {
// Add a middleware to capture the playlistId
wrapper := func(handler restHandler) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
constructor := func(ctx context.Context) rest.Repository {
plsRepo := ds.Playlist(ctx)
plsId := chi.URLParam(req, "playlistId")
return plsRepo.Tracks(plsId, true)
plsId := chi.URLParam(r, "playlistId")
p := req.Params(r)
start := p.Int64Or("_start", 0)
return plsRepo.Tracks(plsId, start == 0)
}
handler(constructor).ServeHTTP(res, req)
handler(constructor).ServeHTTP(w, r)
}
}