Skip to content

Fix/resolve stale menu and wrong account content after account switch#84

Open
themmm wants to merge 1 commit into
philippe44:mainfrom
themmm:fix/issue-64-account-switch-stale-menu
Open

Fix/resolve stale menu and wrong account content after account switch#84
themmm wants to merge 1 commit into
philippe44:mainfrom
themmm:fix/issue-64-account-switch-stale-menu

Conversation

@themmm
Copy link
Copy Markdown

@themmm themmm commented Feb 27, 2026

Disclaimer:

All code-changes have been made with Claude-code.

Changes

Bug 1 — Hardcoded userId in Flow play URL (Plugin.pm)

handleFeed embedded the current userId into a static string at menu-build time for the Flow card's play action. On clients that cache the navigation stack (e.g. Squeezeplay firmware), pressing Play on the Flow card after an account switch would request the old user's radio stream. Fixed by using the dynamic deezer://user.flow URL instead, which is already used by the inner sub-items and resolves against the current player's account at play time via getFlow() in ProtocolHandler.

Bug 2 — Flow toggle closure captured stale userId (Plugin.pm)

The Flow discovery toggle closure captured $userId from handleFeed's outer scope. After an account switch with a cached menu, toggling the setting updated the old account's preference instead of the new one. Fixed by resolving the current userId dynamically inside the closure via getAPIHandler($client)->userId.

Bug 3 — _userQuery auto-computed cache key missing userId (Custom.pm)

When _userQuery is called without an explicit _cacheKey (from _mixes and _smart), the cache key was computed from params+content but without the userId. Two different accounts requesting the same track mix or smart tracklist shared a single cached result — the same class of bug fixed in lms-plugin-tidal#81. Fixed by appending the userId to the hash input. Callers that supply an explicit _cacheKey (_home, _pageItems) are not affected.

Fixes #64

Three bugs caused menu items and personalized content to not update
correctly after switching Deezer accounts (issue philippe44#64):

1. The Flow 'play' URL in handleFeed embedded the userId at menu-build
   time ('deezer://user/$id/flow.dzr'). On clients that cache the
   navigation stack (e.g. Squeezeplay firmware), pressing play on Flow
   after an account switch would still request the old user's flow stream.
   Fixed by using 'deezer://user.flow' instead, which already handled by
   getFlow() in ProtocolHandler and resolves against the current player's
   account at play time.

2. The Flow discovery toggle closure captured $userId from handleFeed's
   outer scope. After an account switch with a cached menu, toggling the
   setting would update the old account's preference. Fixed by calling
   getAPIHandler($client)->userId inside the closure.

3. _userQuery in Custom.pm omitted the userId when auto-computing cache
   keys (used by _mixes and _smart). Two different accounts requesting
   the same track mix or smart tracklist would share a single cached
   result. Fixed by appending $self->userId to the hash input. Callers
   that supply an explicit _cacheKey (e.g. _home, _pageItems) are not
   affected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main Menu items not updated after account switch

1 participant