From 9bd55250dc384de5e119d76d5cbfe526feb8700e Mon Sep 17 00:00:00 2001 From: themmm Date: Fri, 27 Feb 2026 08:00:20 +0100 Subject: [PATCH] fix: resolve stale menu and wrong account content after account switch Three bugs caused menu items and personalized content to not update correctly after switching Deezer accounts (issue #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 --- Custom.pm | 1 + Plugin.pm | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Custom.pm b/Custom.pm index 708a9b2..395a8ea 100644 --- a/Custom.pm +++ b/Custom.pm @@ -469,6 +469,7 @@ sub _userQuery { # very lenghty (Perl hash key order is undetermined). $cacheKey = join(':', map { $_ . $params->{$_} } sort grep { $_ !~ /^_/ } keys %$params ); $cacheKey .= join(':', map { $_ . $content->{$_} } sort keys %$content) if $content && %$content; + $cacheKey .= ':' . $self->userId if $self->userId; $cacheKey = md5_hex($cacheKey); } diff --git a/Plugin.pm b/Plugin.pm index df33baf..356c61e 100644 --- a/Plugin.pm +++ b/Plugin.pm @@ -284,7 +284,7 @@ sub handleFeed { },{ name => cstring($client, 'PLUGIN_DEEZER_FLOW'), image => 'plugins/Deezer/html/flow.png', - play => 'deezer://user/' . $userId . '/flow.dzr', + play => 'deezer://user.flow', type => 'outline', items => [{ name => cstring($client, 'PLUGIN_DEEZER_FLOW'), @@ -311,13 +311,14 @@ sub handleFeed { type => 'link', url => sub { my ($client, $cb) = @_; - my $flow = !$prefs->get($userId . ':flow'); - $prefs->set($userId . ':flow', $flow); + my $currentUserId = getAPIHandler($client)->userId; + my $flow = !$prefs->get($currentUserId . ':flow'); + $prefs->set($currentUserId . ':flow', $flow); $cb->({ items => [{ type => 'text', name => cstring($client, $flow ? 'PLUGIN_DEEZER_FLOW_DISCOVERY' : 'PLUGIN_DEEZER_FLOW_DEFAULT'), }] }); - }, + }, }, ], },{