From 167d82adc061078102fa9984d29f94735d052ce9 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 11 Oct 2024 19:56:32 +0800 Subject: [PATCH 1/2] fix: withdraw availableBalance --- .../src/modules/power/my-wallet-section/withdraw.tsx | 6 ++---- apps/renderer/src/modules/wallet/balance.tsx | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/renderer/src/modules/power/my-wallet-section/withdraw.tsx b/apps/renderer/src/modules/power/my-wallet-section/withdraw.tsx index 2a6542ff5..b2677d228 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/withdraw.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/withdraw.tsx @@ -94,15 +94,13 @@ const WithdrawModalContent = ({ dismiss }: { dismiss: () => void }) => { i18nKey="wallet.withdraw.availableBalance" components={{ Balance: ( - + {wallet.data?.[0].cashablePowerToken || "0"} ), }} ns="settings" - > - {wallet.data?.[0].cashablePowerToken || "0"} - + />
diff --git a/apps/renderer/src/modules/wallet/balance.tsx b/apps/renderer/src/modules/wallet/balance.tsx index f8fa8b2a4..42d548955 100644 --- a/apps/renderer/src/modules/wallet/balance.tsx +++ b/apps/renderer/src/modules/wallet/balance.tsx @@ -6,6 +6,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "../../components/ui/too export const Balance = ({ children, + value, className, precision = 0, withSuffix = false, @@ -13,12 +14,13 @@ export const Balance = ({ }: { /** The token balance in wei. */ children: bigint | string + value?: bigint | string className?: string precision?: number withSuffix?: boolean withTooltip?: boolean }) => { - const n = [BigInt(children || 0n), 18] as const + const n = [BigInt(children) || BigInt(value || 0n), 18] as const const formatted = format(n, { digits: precision, trailingZeros: true }) const formattedFull = format(n, { digits: 18, trailingZeros: true }) From a6abd058ac691c0116f625f9226bd465f6319f25 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 11 Oct 2024 21:30:24 +0800 Subject: [PATCH 2/2] fix: discover search optimistic update data Signed-off-by: Innei --- apps/renderer/src/modules/discover/form.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/renderer/src/modules/discover/form.tsx b/apps/renderer/src/modules/discover/form.tsx index d17d23ba3..11d3c36e5 100644 --- a/apps/renderer/src/modules/discover/form.tsx +++ b/apps/renderer/src/modules/discover/form.tsx @@ -145,9 +145,15 @@ export function DiscoverForm({ type = "search" }: { type?: string }) { jotaiStore.set( discoverSearchDataAtom, produce(currentData, (draft) => { - const sub = draft.find( - (i) => i.feed?.id === item.feed?.id || i.list?.id === item.list?.id, - ) + const sub = draft.find((i) => { + if (item.feed) { + return i.feed?.id === item.feed.id + } + if (item.list) { + return i.list?.id === item.list.id + } + return false + }) if (!sub) return sub.isSubscribed = true sub.subscriptionCount = -~(sub.subscriptionCount as number)