Skip to content

Commit 1e2e0a6

Browse files
authored
[PE-7252] Always show user's launched coin (#13334)
### Description If a user has launched an artist coin we should always show it in their "Your Coins" section even if they have 0 balance, so that they access fee + vested coins claiming. ### How Has This Been Tested? with 0 balance on $REED: <img width="1920" height="1080" alt="Screenshot 2025-10-29 at 3 27 53 PM" src="https://github.com/user-attachments/assets/b463c3d3-b0be-49ed-8bc1-16ad1e94ea37" /> with balance on $REED: <img width="1920" height="1080" alt="Screenshot 2025-10-29 at 3 27 01 PM" src="https://github.com/user-attachments/assets/02edf1bf-3047-437d-a093-ccc573a93b86" />
1 parent da27d25 commit 1e2e0a6

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

packages/mobile/src/screens/wallet-screen/components/YourCoins.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React, { useCallback } from 'react'
22

33
import {
4+
useArtistOwnedCoin,
45
useCurrentUserId,
56
useQueryContext,
67
useUserCoins
78
} from '@audius/common/api'
8-
import { ownedCoinsFilter } from '@audius/common/hooks'
99
import { buySellMessages, walletMessages } from '@audius/common/messages'
1010
import { AUDIO_TICKER } from '@audius/common/store'
11+
import { removeNullable } from '@audius/common/utils'
1112
import { TouchableOpacity } from 'react-native'
1213

1314
import {
@@ -96,13 +97,25 @@ export const YourCoins = () => {
9697
const { data: artistCoins, isPending: isLoadingCoins } = useUserCoins({
9798
userId: currentUserId
9899
})
99-
100-
const filteredCoins =
101-
artistCoins?.filter(ownedCoinsFilter(env.WAUDIO_MINT_ADDRESS)) ?? []
100+
const { data: artistOwnedCoin } = useArtistOwnedCoin(currentUserId)
101+
const audioCoin = artistCoins?.find(
102+
(coin) => coin?.mint === env.WAUDIO_MINT_ADDRESS
103+
)
104+
const otherCoins = artistCoins?.filter(
105+
(coin) =>
106+
coin?.mint !== env.WAUDIO_MINT_ADDRESS &&
107+
coin?.mint !== artistOwnedCoin?.mint &&
108+
coin?.balance > 0
109+
)
110+
const orderedCoins = [
111+
audioCoin,
112+
artistOwnedCoin,
113+
...(otherCoins ?? [])
114+
].filter(removeNullable)
102115

103116
// Show audio coin card when no coins are available
104117
const coins =
105-
filteredCoins.length === 0 ? ['audio-coin' as const] : filteredCoins
118+
orderedCoins.length === 0 ? ['audio-coin' as const] : orderedCoins
106119

107120
// Add discover artist coins card at the end
108121
const cards = [...coins, 'discover-artist-coins' as const]

packages/web/src/pages/pay-and-earn-page/components/YourCoins.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import { Fragment, useCallback, useContext, useState } from 'react'
33
import {
44
UserCoin,
55
useArtistCoin,
6+
useArtistOwnedCoin,
67
useCurrentUserId,
78
useQueryContext,
89
useUserCoins
910
} from '@audius/common/api'
1011
import {
1112
useFeatureFlag,
1213
useFormattedCoinBalance,
13-
useIsManagedAccount,
14-
ownedCoinsFilter
14+
useIsManagedAccount
1515
} from '@audius/common/hooks'
1616
import { buySellMessages, walletMessages } from '@audius/common/messages'
1717
import { FeatureFlags } from '@audius/common/services'
1818
import { useBuySellModal } from '@audius/common/store'
19-
import { route } from '@audius/common/utils'
19+
import { removeNullable, route } from '@audius/common/utils'
2020
import {
2121
Box,
2222
Button,
@@ -267,15 +267,28 @@ export const YourCoins = () => {
267267
const { data: artistCoins, isPending: isLoadingCoins } = useUserCoins({
268268
userId: currentUserId
269269
})
270+
const { data: artistOwnedCoin } = useArtistOwnedCoin(currentUserId)
271+
const audioCoin = artistCoins?.find(
272+
(coin) => coin?.mint === env.WAUDIO_MINT_ADDRESS
273+
)
274+
const otherCoins = artistCoins?.filter(
275+
(coin) =>
276+
coin?.mint !== env.WAUDIO_MINT_ADDRESS &&
277+
coin?.mint !== artistOwnedCoin?.mint &&
278+
coin?.balance > 0
279+
)
280+
// Ensure that the artist owned coin appears first in the list
281+
const orderedCoins = [
282+
audioCoin,
283+
artistOwnedCoin,
284+
...(otherCoins ?? [])
285+
].filter(removeNullable)
270286

271287
const { isLarge } = useMedia()
272288

273-
const filteredCoins =
274-
artistCoins?.filter(ownedCoinsFilter(env.WAUDIO_MINT_ADDRESS)) ?? []
275-
276289
// Show audio coin card when no coins are available
277290
const coins =
278-
filteredCoins.length === 0 ? ['audio-coin' as const] : filteredCoins
291+
orderedCoins.length === 0 ? ['audio-coin' as const] : orderedCoins
279292
// Add discover artist coins card at the end
280293
const allCoins = [...coins, 'discover-artist-coins' as const]
281294

0 commit comments

Comments
 (0)