fix(likes): the web marks every copy of a liked song, not only the one tapped (#8126)
A like is on the song: the server likes every copy sharing its song_key, but the web's optimistic update marked only the tapped track, so the same song on another album or a compilation showed an empty heart until the liked ids were fetched again. A track like or unlike now answers 200 with the ids of every copy it changed, the asked one first, and the web marks them all. Clients that ignore the body (Android) are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-4
@@ -50,10 +50,18 @@ func (h *handlers) handleLikeTrack(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
// The like is on the song: every copy it reached changes on
|
||||
// the client too.
|
||||
for _, t := range eventbus.LedBy(id, liked) {
|
||||
changed := eventbus.LedBy(id, liked)
|
||||
for _, t := range changed {
|
||||
h.publishLikeEvent(user.ID, t, "track", true)
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
writeJSON(w, http.StatusOK, trackLikeView{TrackIDs: uuidsToStrings(changed)})
|
||||
}
|
||||
|
||||
// trackLikeView answers a track like or unlike: the copies of the song it
|
||||
// changed, the one asked for first, so the client can mark them all at once
|
||||
// rather than only the copy that was tapped.
|
||||
type trackLikeView struct {
|
||||
TrackIDs []string `json:"track_ids"`
|
||||
}
|
||||
|
||||
func (h *handlers) handleUnlikeTrack(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -76,10 +84,11 @@ func (h *handlers) handleUnlikeTrack(w http.ResponseWriter, r *http.Request) {
|
||||
h.logger.Error("api: soft-delete contextual_likes", "err", err)
|
||||
// Don't fail the response — soft-delete is best-effort.
|
||||
}
|
||||
for _, t := range eventbus.LedBy(id, unliked) {
|
||||
changed := eventbus.LedBy(id, unliked)
|
||||
for _, t := range changed {
|
||||
h.publishLikeEvent(user.ID, t, "track", false)
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
writeJSON(w, http.StatusOK, trackLikeView{TrackIDs: uuidsToStrings(changed)})
|
||||
}
|
||||
|
||||
func (h *handlers) handleLikeAlbum(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user