Update account balance calculation to use latest balances - #13378
Conversation
|
| userId | ||
| }: UseUserTotalBalanceParams = {}): UseUserTotalBalanceResult => { | ||
| const { data: currentUserId } = useCurrentUserId() | ||
| const effectiveUserId = userId ?? currentUserId |
There was a problem hiding this comment.
nit: using the naming "effective" is a bit odd to me, personally I would prefer not destructuring userId from params and doing userId = params.userId ?? or something along those lines
There was a problem hiding this comment.
Yeah we should just drop this since it's always for account user
|
|
||
| const firstBalance = historyData[0].balanceUsd | ||
| const lastBalance = historyData[historyData.length - 1].balanceUsd | ||
| const lastBalance = currentBalance |
There was a problem hiding this comment.
nit: kind of unnecessary var creation?
| const { | ||
| totalBalance: currentBalance, | ||
| isLoading: isBalanceLoading, | ||
| isError: isBalanceError | ||
| } = useUserTotalBalance({ userId: effectiveUserId }) | ||
|
|
||
| const historyData = useMemo(() => { | ||
| if (!historyDataFetched || historyDataFetched.length === 0) { | ||
| return historyDataFetched | ||
| } | ||
|
|
||
| const currentTimestamp = Date.now() | ||
| return [ | ||
| ...historyDataFetched, | ||
| { | ||
| timestamp: currentTimestamp, | ||
| balanceUsd: currentBalance | ||
| } | ||
| ] | ||
| }, [historyDataFetched, currentBalance]) |
There was a problem hiding this comment.
nit: seems like this would be more elegant as a select option on the query
### Description Updates account-balance to use latest balances Updates user-balance-history-graph to use latest-balance as the last datum Ensures we get optimistic updates on all balance changes
[ed3e17b] [PE-7304] Fix upload saga test (#13387) Reed [a6fba10] [PE-7303] Portfolio balance qa (#13380) Dylan Jeffers [9d53680] [PE-7292] DAMM swaps with meteora (#13381) JD Francis [14a6ad9] [PE-7250] CoinDetailPage Tests + Integration test reorg (#12820) JD Francis [9a48c52] Remove hello in SummaryTable (#13382) Reed [8f98e4f] [PE-7241] Fix web ProfilePage test (#13371) Reed [619541f] Silver tier for endless streak (#13319) Ray Jacobson [f403ecc] [PE-7302] Fix USDC image quality (#13379) Dylan Jeffers [39fadcc] Update account balance calculation to use latest balances (#13378) Dylan Jeffers [fea5e65] Drop decimals to fix swaps (#13377) Dylan Jeffers [e0966af] [PE-7293] Prefer Meteora for external wallet swaps (#13374) Dylan Jeffers [4ca25ba] Version Packages (#13343) github-actions[bot] [c2f9700] [PE-7272] Fallback to meteora DBC swaps when jupiter fails (#13352) JD Francis [e4f738e] Remove account requirement for unlock track modal coin buy (#13370) KJ [b41179f] Add suppress any error ts config option back (#13369) KJ [f831437] Dbc swaps relay sdk changes (#13368) JD Francis [760c602] [PE-7283] Fix sign up route on completion logic (#13366) KJ [c734ca5] [PE-7282] Update signup flow to remove social signup and profile pic requirement (#13367) KJ [c879838] [PE-7280] Enable 16KB page size support for Android 15+ (#13365) Dylan Jeffers [6e94428] [PE-7279] Fix wallet static page (#13364) Dylan Jeffers [11b541a] [PE-2834] Fix balance history hover issue (#13363) Dylan Jeffers [e918b01] [QA-2386] Fix portfolio icon (#13362) Dylan Jeffers [18141c7] [PE-7260 PE-7258] Mobile wallet page updates (#13360) Dylan Jeffers [16e1656] Remove feature flags (#13358) Dylan Jeffers [25cdbfd] Add TradingVolumeLaunchBanner (#13359) Ray Jacobson [f1c942f]⚠️ [PE-7269] Upgrade cipher-base to 1.0.7 (#13357) Reed [e51a55c] [PE-7270] useArtistCreatedCoin instead of useUserCreatedCoins (#13354) Reed [76d6e86] [PE-7277] Hide chat blast coin holder audience if no coin (#13353) Reed
Description
Updates account-balance to use latest balances
Updates user-balance-history-graph to use latest-balance as the last datum
Ensures we get optimistic updates on all balance changes