From 5232f948a1a25fa5bbfc96a17264859d828713bc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 24 Apr 2025 14:17:36 -0500 Subject: [PATCH] Hotfix cashu performance issue --- .vscode/settings.json | 3 ++- src/components/pure-status-action-bar.tsx | 6 +----- src/components/status-action-bar.tsx | 6 +----- src/features/ui/components/pocket-wallet.tsx | 12 ++++++------ src/pages/home-page.tsx | 4 +--- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3eef3018c..3816346fe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,5 +23,6 @@ "javascript.preferences.importModuleSpecifierEnding": "js", "javascript.preferences.importModuleSpecifier": "non-relative", "typescript.preferences.importModuleSpecifierEnding": "js", - "typescript.preferences.importModuleSpecifier": "non-relative" + "typescript.preferences.importModuleSpecifier": "non-relative", + "deno.enable": false } diff --git a/src/components/pure-status-action-bar.tsx b/src/components/pure-status-action-bar.tsx index d1f646f23..1333c7365 100644 --- a/src/components/pure-status-action-bar.tsx +++ b/src/components/pure-status-action-bar.tsx @@ -48,7 +48,6 @@ import DropdownMenu from 'soapbox/components/dropdown-menu/index.ts'; import PureStatusReactionWrapper from 'soapbox/components/pure-status-reaction-wrapper.tsx'; import StatusActionButton from 'soapbox/components/status-action-button.tsx'; import HStack from 'soapbox/components/ui/hstack.tsx'; -import { useZapCashuRequest } from 'soapbox/features/zap/hooks/useHooks.ts'; import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts'; import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts'; import { useDislike } from 'soapbox/hooks/useDislike.ts'; @@ -180,9 +179,6 @@ const PureStatusActionBar: React.FC = ({ const features = useFeatures(); const { boostModal, deleteModal } = useSettings(); - const { zapCashuList } = useZapCashuRequest(); - const isZappedCashu = zapCashuList.some((zapCashu)=> zapCashu === status.id); - const { account } = useOwnAccount(); const isStaff = account ? account.staff : false; const isAdmin = account ? account.admin : false; @@ -854,7 +850,7 @@ const PureStatusActionBar: React.FC = ({ color='accent' filled onClick={handleZapClick} - active={status.zapped_cashu || status.zapped || isZappedCashu} + active={status.zapped_cashu || status.zapped} theme={statusActionButtonTheme} count={(status?.zaps_amount ?? 0) / 1000 + (status?.zaps_amount_cashu ?? 0)} /> diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index c2c7a8e73..86e0d46d9 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -49,7 +49,6 @@ import DropdownMenu from 'soapbox/components/dropdown-menu/index.ts'; import StatusActionButton from 'soapbox/components/status-action-button.tsx'; import StatusReactionWrapper from 'soapbox/components/status-reaction-wrapper.tsx'; import HStack from 'soapbox/components/ui/hstack.tsx'; -import { useZapCashuRequest } from 'soapbox/features/zap/hooks/useHooks.ts'; import { useAppDispatch } from 'soapbox/hooks/useAppDispatch.ts'; import { useAppSelector } from 'soapbox/hooks/useAppSelector.ts'; import { useFeatures } from 'soapbox/hooks/useFeatures.ts'; @@ -175,9 +174,6 @@ const StatusActionBar: React.FC = ({ const features = useFeatures(); const { boostModal, deleteModal } = useSettings(); - const { zapCashuList } = useZapCashuRequest(); - const isZappedCashu = zapCashuList.some((zapCashu)=> zapCashu === status.id); - const { account } = useOwnAccount(); const isStaff = account ? account.staff : false; const isAdmin = account ? account.admin : false; @@ -844,7 +840,7 @@ const StatusActionBar: React.FC = ({ color='accent' filled onClick={handleZapClick} - active={status.zapped_cashu || status.zapped || isZappedCashu} + active={status.zapped_cashu || status.zapped} theme={statusActionButtonTheme} count={(status?.zaps_amount ?? 0) / 1000 + (status?.zaps_amount_cashu ?? 0)} /> diff --git a/src/features/ui/components/pocket-wallet.tsx b/src/features/ui/components/pocket-wallet.tsx index b7dd6485c..32b9af1ab 100644 --- a/src/features/ui/components/pocket-wallet.tsx +++ b/src/features/ui/components/pocket-wallet.tsx @@ -35,6 +35,10 @@ const PocketWallet = () => { localStorage.setItem('soapbox:wallet:eye', JSON.stringify(eyeClosed)); }, [eyeClosed]); + if (!wallet) { + return null; + } + return ( @@ -48,7 +52,7 @@ const PocketWallet = () => { {!expanded && <> { eyeClosed ? {intl.formatMessage({ id: 'wallet.hidden.balance', defaultMessage: '••••••' })} : - {intl.formatMessage(messages.balance, { amount: wallet?.balance })} + {intl.formatMessage(messages.balance, { amount: wallet.balance })} }