Fix favorite heart state resetting on queue updates for radio and provider items#1725
Open
dmoo500 wants to merge 1 commit into
Open
Fix favorite heart state resetting on queue updates for radio and provider items#1725dmoo500 wants to merge 1 commit into
dmoo500 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a radio station or provider track (not yet in the library) was playing and the user favorited it, the heart button in the fullscreen player would briefly light up and then reset to empty. This happened on every subsequent queue update from the server.
Root cause:
store.curQueueItemis derived fromactivePlayerQueue.current_item, which the server pushes as a complete replacement object on every queue event. When the item was enqueued withfavorite: false, all server-side queue updates kept sending that original value — overwriting any optimistic local change made bytoggleFavorite.Library tracks that were already favorited before being enqueued were not affected because their
favorite: truewas baked in at enqueue time.Fix
Introduce a local
currentItemFavoriteref that lives independently of the server-pushedmedia_itemobject:media_item.favoritewhenever the queue item changes (watch onqueue_item_id)true/falseinonHeartBtnClick— survives server queue refreshes because it is not part of the replaced objectMEDIA_ITEM_UPDATEDsubscription: when the server confirms the favorite change (URI match),currentItemFavoriteis updated to the server's valueThe template heart fill and the "already favorited" branch in
onHeartBtnClicknow readcurrentItemFavoriteinstead ofstore.curQueueItem?.media_item?.favorite.