From 54b6ac5dae717a210d47c1ee7adb13399b45d4df Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Apr 2026 20:54:10 +0000 Subject: [PATCH 1/2] Fix fan club feed staying locked after buying artist coins After a coin purchase (internal or external wallet), the fan club feed and individual comment queries were not invalidated. Since comments use staleTime: Infinity and cache message as null for locked content, they never refetched until a page refresh. Now invalidate fan club feed and comment queries after successful swaps. https://claude.ai/code/session_012LBscuBu5YkpEhEwkgK95t --- .../src/api/tan-query/jupiter/useSwapCoins.ts | 20 ++++++++++++++++++- .../src/store/ui/buy-sell/useBuySellSwap.ts | 19 +++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/common/src/api/tan-query/jupiter/useSwapCoins.ts b/packages/common/src/api/tan-query/jupiter/useSwapCoins.ts index f1b8608bc49..857007ea29a 100644 --- a/packages/common/src/api/tan-query/jupiter/useSwapCoins.ts +++ b/packages/common/src/api/tan-query/jupiter/useSwapCoins.ts @@ -6,8 +6,10 @@ import { getArtistCoinQueryKey, updateAudioBalanceOptimistically, useCurrentAccountUser, - useQueryContext + useQueryContext, + getFanClubFeedQueryKey } from '~/api' +import { QUERY_KEYS } from '~/api/tan-query/queryKeys' import type { QueryContextType } from '~/api/tan-query/utils/QueryContext' import { Feature } from '~/models' import type { User } from '~/models/User' @@ -189,6 +191,22 @@ export const optimisticallyUpdateSwapBalances = ( }) } + // Invalidate fan club feed and comment queries so locked content is re-evaluated + if (inputMint && !isInputAudio) { + queryClient.invalidateQueries({ + queryKey: getFanClubFeedQueryKey({ mint: inputMint }) + }) + } + if (outputMint && !isOutputAudio) { + queryClient.invalidateQueries({ + queryKey: getFanClubFeedQueryKey({ mint: outputMint }) + }) + } + // Invalidate individual comment queries so locked posts refetch with access + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.comment] + }) + // Invalidate user query to ensure user data is fresh after swap queryClient.invalidateQueries({ queryKey: getUserQueryKey(user?.user_id) diff --git a/packages/common/src/store/ui/buy-sell/useBuySellSwap.ts b/packages/common/src/store/ui/buy-sell/useBuySellSwap.ts index a2c6a6f295d..169867717b8 100644 --- a/packages/common/src/store/ui/buy-sell/useBuySellSwap.ts +++ b/packages/common/src/store/ui/buy-sell/useBuySellSwap.ts @@ -6,7 +6,8 @@ import { SLIPPAGE_BPS, useArtistCoin, useCurrentAccountUser, - getArtistCoinQueryKey + getArtistCoinQueryKey, + getFanClubFeedQueryKey } from '~/api' import { SwapStatus, SwapTokensResult } from '~/api/tan-query/jupiter/types' import { TQTrack } from '~/api/tan-query/models' @@ -132,6 +133,22 @@ export const useBuySellSwap = (props: UseBuySellSwapProps) => { }) } + // Invalidate fan club feed and comment queries so locked content is re-evaluated + if (baseCoin?.mint) { + queryClient.invalidateQueries({ + queryKey: getFanClubFeedQueryKey({ mint: baseCoin.mint }) + }) + } + if (quoteCoin?.mint) { + queryClient.invalidateQueries({ + queryKey: getFanClubFeedQueryKey({ mint: quoteCoin.mint }) + }) + } + // Invalidate individual comment queries so locked posts refetch with access + queryClient.invalidateQueries({ + queryKey: [QUERY_KEYS.comment] + }) + // Invalidate track queries to provide track access if the user has traded the artist coin const baseOwnerId = baseCoin?.ownerId ?? null const quoteOwnerId = quoteCoin?.ownerId ?? null From 8528e672853adccad50ea7b2877d8e09d89c4a08 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 3 Apr 2026 21:00:08 +0000 Subject: [PATCH 2/2] Add changeset for fan club locked content fix https://claude.ai/code/session_012LBscuBu5YkpEhEwkgK95t --- .changeset/fix-fan-club-locked-content.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-fan-club-locked-content.md diff --git a/.changeset/fix-fan-club-locked-content.md b/.changeset/fix-fan-club-locked-content.md new file mode 100644 index 00000000000..bbca890985b --- /dev/null +++ b/.changeset/fix-fan-club-locked-content.md @@ -0,0 +1,5 @@ +--- +"@audius/common": patch +--- + +Invalidate fan club feed and comment queries after coin swaps so locked content unlocks without requiring a page refresh