Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-fan-club-locked-content.md
Original file line number Diff line number Diff line change
@@ -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
20 changes: 19 additions & 1 deletion packages/common/src/api/tan-query/jupiter/useSwapCoins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 18 additions & 1 deletion packages/common/src/store/ui/buy-sell/useBuySellSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Loading