From d4f3611464cd62ba6cd475a925bc18eb1d449953 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 07:30:40 -0300 Subject: [PATCH 01/17] feat: tx history optimizations --- .../main/SideBar/components/Wallet/Wallet.tsx | 12 ++++++------ src/hooks/mining/useMiningStatesSync.ts | 15 ++++----------- src/hooks/mining/useTransactions.ts | 6 ++++-- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/containers/main/SideBar/components/Wallet/Wallet.tsx b/src/containers/main/SideBar/components/Wallet/Wallet.tsx index f1abb2617..3881ea67b 100644 --- a/src/containers/main/SideBar/components/Wallet/Wallet.tsx +++ b/src/containers/main/SideBar/components/Wallet/Wallet.tsx @@ -62,16 +62,16 @@ export default function Wallet() { const toggleBalanceVisibility = () => setShowBalance((prev) => !prev); const displayValue = balance === null ? '-' : showBalance ? formatted : '*****'; - const handleShowClick = useCallback(() => { + const handleShowClick = useCallback(async () => { if (balance && !transactions.length && !isTransactionLoading) { - fetchTx().then(() => setShowHistory((c) => !c)); - return; + await fetchTx(); + } else { + setRecapCount(undefined); } - setRecapCount(undefined); - setShowHistory((c) => !c); - }, [balance, fetchTx, isTransactionLoading, setRecapCount, transactions?.length]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [balance, fetchTx, isTransactionLoading, transactions?.length]); const handleSyncButtonClick = () => { setShowPaperWalletModal(true); diff --git a/src/hooks/mining/useMiningStatesSync.ts b/src/hooks/mining/useMiningStatesSync.ts index 1250fcce3..0c6160fb6 100644 --- a/src/hooks/mining/useMiningStatesSync.ts +++ b/src/hooks/mining/useMiningStatesSync.ts @@ -20,22 +20,15 @@ export function useMiningStatesSync() { useUiMiningStateMachine(); useEarningsRecap(); - const callIntervalItems = useCallback(async () => { - if (setupProgress >= 0.75) { - await fetchWalletDetails(); - } - }, [fetchWalletDetails, setupProgress]); - // intervalItems useEffect(() => { - const fetchInterval = setInterval(async () => { - await callIntervalItems(); - }, 1000); - + if (setupProgress < 0.75) return; + const fetchInterval = setInterval(fetchWalletDetails, 1000); return () => { clearInterval(fetchInterval); }; - }, [callIntervalItems]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [setupProgress]); useEffect(() => { if (isSettingUp) return; diff --git a/src/hooks/mining/useTransactions.ts b/src/hooks/mining/useTransactions.ts index cddf30a08..e9bbb7686 100644 --- a/src/hooks/mining/useTransactions.ts +++ b/src/hooks/mining/useTransactions.ts @@ -21,7 +21,8 @@ export default function useFetchTx() { setTransactions(newTx); } }, - [setTransactions, transactions] + // eslint-disable-next-line react-hooks/exhaustive-deps + [transactions] ); return useCallback(async () => { @@ -54,5 +55,6 @@ export default function useFetchTx() { } finally { setTransactionsLoading(false); } - }, [isTransactionLoading, setItems, setTransactionsLoading, setupProgress]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isTransactionLoading, setupProgress]); } From d50a36338bccf61bb452b3ffa4f0ee75b4712145 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 07:36:10 -0300 Subject: [PATCH 02/17] removes unused import --- src/hooks/mining/useMiningStatesSync.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/mining/useMiningStatesSync.ts b/src/hooks/mining/useMiningStatesSync.ts index 0c6160fb6..360301b98 100644 --- a/src/hooks/mining/useMiningStatesSync.ts +++ b/src/hooks/mining/useMiningStatesSync.ts @@ -1,6 +1,6 @@ import { MinerMetrics } from '@app/types/app-status'; import { listen } from '@tauri-apps/api/event'; -import { useCallback, useEffect } from 'react'; +import { useEffect } from 'react'; import { useWalletStore } from '@app/store/useWalletStore.ts'; import { useAppStateStore } from '@app/store/appStateStore'; From 43ca75021b05c2d7a39a32177e38afb864888b84 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 07:38:26 -0300 Subject: [PATCH 03/17] comments out unused sentry settings --- src/App/AppWrapper.tsx | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/App/AppWrapper.tsx b/src/App/AppWrapper.tsx index 160de9c7e..668e61126 100644 --- a/src/App/AppWrapper.tsx +++ b/src/App/AppWrapper.tsx @@ -1,12 +1,12 @@ import { useEffect } from 'react'; -import { defaultOptions } from 'tauri-plugin-sentry-api'; -import * as Sentry from '@sentry/react'; -import { IGNORE_FETCHING } from '@app/App/sentryIgnore'; +// import { defaultOptions } from 'tauri-plugin-sentry-api'; +// import * as Sentry from '@sentry/react'; +// import { IGNORE_FETCHING } from '@app/App/sentryIgnore'; import { initSystray } from '@app/utils'; import { useDetectMode, useDisableRefresh, useLangaugeResolver, useListenForExternalDependencies } from '@app/hooks'; -import packageInfo from '../../package.json'; +// import packageInfo from '../../package.json'; import { useAppConfigStore } from '../store/useAppConfigStore.ts'; import setupLogger from '../utils/shared-logger.ts'; import App from './App.tsx'; @@ -15,21 +15,21 @@ import { useMiningStore } from '@app/store/useMiningStore.ts'; // FOR ANYTHING THAT NEEDS TO BE INITIALISED -const environment = import.meta.env.MODE; -const sentryOptions = { - ...defaultOptions, - dsn: 'https://edd6b9c1494eb7fda6ee45590b80bcee@o4504839079002112.ingest.us.sentry.io/4507979991285760', - integrations: [Sentry.captureConsoleIntegration({ levels: ['warn', 'error'] }), Sentry.extraErrorDataIntegration()], - release: packageInfo.version, - environment, - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - tracesSampleRate: 1.0, - attachStacktrace: true, - autoSessionTracking: false, - ignoreErrors: [...IGNORE_FETCHING], - enabled: environment !== 'development', -}; +// const environment = import.meta.env.MODE; +// const sentryOptions = { +// ...defaultOptions, +// dsn: 'https://edd6b9c1494eb7fda6ee45590b80bcee@o4504839079002112.ingest.us.sentry.io/4507979991285760', +// integrations: [Sentry.captureConsoleIntegration({ levels: ['warn', 'error'] }), Sentry.extraErrorDataIntegration()], +// release: packageInfo.version, +// environment, +// // Set tracesSampleRate to 1.0 to capture 100% +// // of transactions for tracing. +// tracesSampleRate: 1.0, +// attachStacktrace: true, +// autoSessionTracking: false, +// ignoreErrors: [...IGNORE_FETCHING], +// enabled: environment !== 'development', +// }; setupLogger(); From a5b76f617b8f6cd0354d6478db8b4ae3d668a0a8 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 08:28:02 -0300 Subject: [PATCH 04/17] minor tweak on txs --- src/components/ToastStack/Toast/Toast.tsx | 12 +++++------- .../floating/AutoUpdateDialog/AutoUpdateDialog.tsx | 6 ++++-- src/containers/floating/Error/ErrorSnackbar.tsx | 14 ++++++-------- .../Settings/sections/airdrop/ApplyInviteCode.tsx | 9 ++++++--- .../floating/Settings/sections/p2p/P2PoolStats.tsx | 3 ++- .../sections/LoggedIn/segments/Flare/Flare.tsx | 8 ++++---- .../sections/LoggedOut/LoggedOut.tsx | 6 ++++-- .../SoSWidget/segments/Timer/Timer.tsx | 5 +++-- .../CustomPowerLevelsDialogContainer.tsx | 3 ++- .../OrphanChainAlert/OrphanChainAlert.tsx | 2 +- .../main/SideBar/components/Wallet/History.tsx | 10 ++++++---- .../main/SideBar/components/Wallet/HistoryItem.tsx | 1 - .../main/SideBar/components/Wallet/Wallet.tsx | 11 ++++++----- .../stateHelpers/useAirdropTokensRefresh.ts | 3 ++- .../stateHelpers/useAirdropUserPointsListener.ts | 3 ++- src/hooks/airdrop/useWebsocket.ts | 11 ++--------- src/hooks/app/useListenForExternalDependencies.ts | 3 ++- src/hooks/app/useSetUp.ts | 7 +++++-- src/hooks/helpers/useDetectMode.ts | 3 ++- src/hooks/mining/useTransactions.ts | 2 +- src/hooks/useListenForCriticalProblem.tsx | 3 ++- 21 files changed, 67 insertions(+), 58 deletions(-) diff --git a/src/components/ToastStack/Toast/Toast.tsx b/src/components/ToastStack/Toast/Toast.tsx index f354eff57..2d6617b8e 100644 --- a/src/components/ToastStack/Toast/Toast.tsx +++ b/src/components/ToastStack/Toast/Toast.tsx @@ -25,13 +25,11 @@ export const Toast = ({ id, index, title, text, timeout = 4500, isHovered = fals const { removeToast } = useToastStore(); const [finished, setFinished] = useState(false); - const handleHide = useCallback( - (id: number | string = 0) => { - setShow(false); - removeToast(id); - }, - [removeToast] - ); + const handleHide = useCallback((id: number | string = 0) => { + setShow(false); + removeToast(id); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); useEffect(() => { setShow(true); diff --git a/src/containers/floating/AutoUpdateDialog/AutoUpdateDialog.tsx b/src/containers/floating/AutoUpdateDialog/AutoUpdateDialog.tsx index fcf0c723b..f00caae53 100644 --- a/src/containers/floating/AutoUpdateDialog/AutoUpdateDialog.tsx +++ b/src/containers/floating/AutoUpdateDialog/AutoUpdateDialog.tsx @@ -61,12 +61,14 @@ export default function AutoUpdateDialog() { return () => { unlistenPromise.then((unlisten) => unlisten()); }; - }, [open, setDialogToShow]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [open]); const handleClose = useCallback(() => { console.info('Update declined'); setDialogToShow(null); - }, [setDialogToShow]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); const handleUpdate = useCallback(() => { console.info('Proceed with update'); diff --git a/src/containers/floating/Error/ErrorSnackbar.tsx b/src/containers/floating/Error/ErrorSnackbar.tsx index 6efb3663a..acfa18fc6 100644 --- a/src/containers/floating/Error/ErrorSnackbar.tsx +++ b/src/containers/floating/Error/ErrorSnackbar.tsx @@ -51,14 +51,12 @@ export default function ErrorSnackbar() { const { getFloatingProps } = useInteractions([dismiss, role]); - const handleClose = useCallback( - (e?: MouseEvent) => { - e?.preventDefault(); - e?.stopPropagation(); - setError(undefined); - }, - [setError] - ); + const handleClose = useCallback((e?: MouseEvent) => { + e?.preventDefault(); + e?.stopPropagation(); + setError(undefined); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); useEffect(() => { setShow(Boolean(error && error?.length)); diff --git a/src/containers/floating/Settings/sections/airdrop/ApplyInviteCode.tsx b/src/containers/floating/Settings/sections/airdrop/ApplyInviteCode.tsx index 21eae8652..114079273 100644 --- a/src/containers/floating/Settings/sections/airdrop/ApplyInviteCode.tsx +++ b/src/containers/floating/Settings/sections/airdrop/ApplyInviteCode.tsx @@ -38,7 +38,8 @@ export const ApplyInviteCode = () => { open(refUrl); }); } - }, [backendInMemoryConfig?.airdropTwitterAuthUrl, claimCode, setAllowTelemetry, setAuthUuid]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [backendInMemoryConfig?.airdropTwitterAuthUrl, claimCode]); const handleToken = useCallback(() => { if (authUuid) { @@ -62,7 +63,8 @@ export const ApplyInviteCode = () => { return false; } - }, [authUuid, backendInMemoryConfig?.airdropApiUrl, setAirdropTokens]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [authUuid, backendInMemoryConfig?.airdropApiUrl]); useEffect(() => { if (authUuid && backendInMemoryConfig?.airdropApiUrl) { @@ -85,7 +87,8 @@ export const ApplyInviteCode = () => { setLoading(false); }; } - }, [authUuid, backendInMemoryConfig?.airdropApiUrl, handleToken, setAuthUuid]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [authUuid, backendInMemoryConfig?.airdropApiUrl, handleToken]); return ( diff --git a/src/containers/floating/Settings/sections/p2p/P2PoolStats.tsx b/src/containers/floating/Settings/sections/p2p/P2PoolStats.tsx index 1263be01f..65ab3f762 100644 --- a/src/containers/floating/Settings/sections/p2p/P2PoolStats.tsx +++ b/src/containers/floating/Settings/sections/p2p/P2PoolStats.tsx @@ -38,7 +38,8 @@ const P2PoolStats = () => { return () => { clearInterval(fetchP2pStatsInterval); }; - }, [fetchP2pStats, fetchP2poolConnections]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); const displayPeers = useMemo(() => { const sha3Height = sha3Stats?.height; diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedIn/segments/Flare/Flare.tsx b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedIn/segments/Flare/Flare.tsx index a1cf6c6d3..dc64ca234 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedIn/segments/Flare/Flare.tsx +++ b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedIn/segments/Flare/Flare.tsx @@ -22,22 +22,22 @@ const durations = { export default function Flare({ gems, animationType }: Props) { const setFlareAnimationType = useAirdropStore((s) => s.setFlareAnimationType); - const clearFlareAnimationType = useCallback(() => setFlareAnimationType(), [setFlareAnimationType]); useEffect(() => { const duration = durations[animationType] || 0; - const animationTimeout = setTimeout(clearFlareAnimationType, duration); + const animationTimeout = setTimeout(setFlareAnimationType, duration); return () => { clearTimeout(animationTimeout); }; - }, [animationType, clearFlareAnimationType]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [animationType]); return ( setFlareAnimationType()} > {animationType === 'GoalComplete' && } {animationType === 'FriendAccepted' && } diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx index 3e8c6fd35..0b9f6ee8c 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx +++ b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx @@ -25,7 +25,8 @@ export default function LoggedOut() { ); } }, - [backendInMemoryConfig?.airdropTwitterAuthUrl, setAuthUuid] + // eslint-disable-next-line react-hooks/exhaustive-deps + [backendInMemoryConfig?.airdropTwitterAuthUrl] ); useEffect(() => { @@ -61,7 +62,8 @@ export default function LoggedOut() { clearTimeout(timeout); }; } - }, [authUuid, backendInMemoryConfig?.airdropApiUrl, restartMining, setAirdropTokens, setAuthUuid, setUserPoints]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [authUuid, backendInMemoryConfig?.airdropApiUrl]); const gemsValue = (referralQuestPoints?.pointsForClaimingReferral || GIFT_GEMS).toLocaleString(); diff --git a/src/containers/main/ShellOfSecrets/SoSWidget/segments/Timer/Timer.tsx b/src/containers/main/ShellOfSecrets/SoSWidget/segments/Timer/Timer.tsx index 6d371e37a..6c5340792 100644 --- a/src/containers/main/ShellOfSecrets/SoSWidget/segments/Timer/Timer.tsx +++ b/src/containers/main/ShellOfSecrets/SoSWidget/segments/Timer/Timer.tsx @@ -14,7 +14,7 @@ import { useEffect, useState } from 'react'; export default function Timer() { const { t } = useTranslation('sos', { useSuspense: false }); - const { getTimeRemaining } = useShellOfSecretsStore(); + const getTimeRemaining = useShellOfSecretsStore((s) => s.getTimeRemaining); const [reminingTime, setRemainingTime] = useState({ days: 0, hours: 0, totalRemainingMs: 0 }); useEffect(() => { @@ -24,7 +24,8 @@ export default function Timer() { return () => { clearInterval(intervalId); }; - }, [getTimeRemaining]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return ( diff --git a/src/containers/main/SideBar/Miner/components/CustomPowerLevels/CustomPowerLevelsDialogContainer.tsx b/src/containers/main/SideBar/Miner/components/CustomPowerLevels/CustomPowerLevelsDialogContainer.tsx index aa8ba115b..5e0f23f21 100644 --- a/src/containers/main/SideBar/Miner/components/CustomPowerLevels/CustomPowerLevelsDialogContainer.tsx +++ b/src/containers/main/SideBar/Miner/components/CustomPowerLevels/CustomPowerLevelsDialogContainer.tsx @@ -19,7 +19,8 @@ export const CustomPowerLevelsDialogContainer = () => { if (!maxThreads) { fetchMaxThreads(); } - }, [fetchMaxThreads, maxThreads]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [maxThreads]); return ( { return () => { unlistenPromise.then((unlisten) => unlisten()); }; - }, [setIsOrphanChain]); + }, []); const steps = Array.from({ length: 6 }).map((_, i) => t(`mining-view:orphan-chain-tooltip.step_${i + 1}`)); diff --git a/src/containers/main/SideBar/components/Wallet/History.tsx b/src/containers/main/SideBar/components/Wallet/History.tsx index c5c741733..00894e8bd 100644 --- a/src/containers/main/SideBar/components/Wallet/History.tsx +++ b/src/containers/main/SideBar/components/Wallet/History.tsx @@ -1,11 +1,10 @@ -import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useWalletStore } from '@app/store/useWalletStore'; import { CircularProgress } from '@app/components/elements/CircularProgress'; -import HistoryItem from './HistoryItem'; import { ListLabel } from './HistoryItem.styles'; import { HistoryContainer, HistoryPadding } from './Wallet.styles'; +import HistoryItem from './HistoryItem'; const container = { hidden: { opacity: 0, height: 0 }, @@ -19,13 +18,16 @@ export default function History() { const { t } = useTranslation('sidebar', { useSuspense: false }); const isTransactionLoading = useWalletStore((s) => s.isTransactionLoading); const transactions = useWalletStore((s) => s.transactions); - const txMarkup = useMemo(() => transactions.map((tx) => ), [transactions]); return ( {t('recent-wins')} - {isTransactionLoading && !transactions?.length ? : txMarkup} + {isTransactionLoading && !transactions?.length ? ( + + ) : ( + transactions.map((tx) => ) + )} ); diff --git a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx index 38222d11d..12081197a 100644 --- a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx +++ b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx @@ -117,7 +117,6 @@ export default function HistoryItem({ item }: HistoryItemProps) { )} - diff --git a/src/containers/main/SideBar/components/Wallet/Wallet.tsx b/src/containers/main/SideBar/components/Wallet/Wallet.tsx index 3881ea67b..49d097ca3 100644 --- a/src/containers/main/SideBar/components/Wallet/Wallet.tsx +++ b/src/containers/main/SideBar/components/Wallet/Wallet.tsx @@ -63,11 +63,12 @@ export default function Wallet() { const displayValue = balance === null ? '-' : showBalance ? formatted : '*****'; const handleShowClick = useCallback(async () => { - if (balance && !transactions.length && !isTransactionLoading) { - await fetchTx(); - } else { - setRecapCount(undefined); - } + // if (balance && !transactions.length && !isTransactionLoading) { + // await fetchTx(); + // } else { + // setRecapCount(undefined); + // } + await fetchTx(); setShowHistory((c) => !c); // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts b/src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts index 060a67bf2..f7c657e18 100644 --- a/src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts +++ b/src/hooks/airdrop/stateHelpers/useAirdropTokensRefresh.ts @@ -40,7 +40,8 @@ export function useHandleAirdropTokensRefresh() { } await setAirdropTokens(fetchedAirdropTokens); }, - [airdropTokens, setAirdropTokens, syncedAidropWithBackend] + // eslint-disable-next-line react-hooks/exhaustive-deps + [airdropTokens, syncedAidropWithBackend] ); } export function useAirdropTokensRefresh() { diff --git a/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts b/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts index 99a9104e5..7995a9a72 100644 --- a/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts +++ b/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts @@ -22,7 +22,8 @@ export const useAirdropUserPointsListener = () => { setUserPoints(pointsPayload); } }, - [bonusTiers, currentReferralData?.count, setFlareAnimationType, setUserPoints] + // eslint-disable-next-line react-hooks/exhaustive-deps + [bonusTiers, currentReferralData?.count] ); useEffect(() => { diff --git a/src/hooks/airdrop/useWebsocket.ts b/src/hooks/airdrop/useWebsocket.ts index 40151f205..faaa41bfd 100644 --- a/src/hooks/airdrop/useWebsocket.ts +++ b/src/hooks/airdrop/useWebsocket.ts @@ -72,15 +72,8 @@ export const useWebsocket = () => { console.error(e); } }, - [ - connectedSocket, - appId, - height, - applicationsVersions?.tari_universe, - network, - userId, - registerWsConnectionEvent, - ] + // eslint-disable-next-line react-hooks/exhaustive-deps + [connectedSocket, appId, height, applicationsVersions?.tari_universe, network, userId] ); useEffect(() => { diff --git a/src/hooks/app/useListenForExternalDependencies.ts b/src/hooks/app/useListenForExternalDependencies.ts index d5586b86e..b110503af 100644 --- a/src/hooks/app/useListenForExternalDependencies.ts +++ b/src/hooks/app/useListenForExternalDependencies.ts @@ -17,5 +17,6 @@ export function useListenForExternalDependencies() { return () => { unlistenPromise.then((unlisten) => unlisten()); }; - }, [loadExternalDependencies, setShowExternalDependenciesDialog]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); } diff --git a/src/hooks/app/useSetUp.ts b/src/hooks/app/useSetUp.ts index cbda61289..badbf25ab 100644 --- a/src/hooks/app/useSetUp.ts +++ b/src/hooks/app/useSetUp.ts @@ -42,10 +42,12 @@ export function useSetUp() { localStorage.setItem('airdrop-store', airdropStorage); } }, []); + const handlePostSetup = useCallback(async () => { await fetchApplicationsVersionsWithRetry(); await setSettingUpFinished(); - }, [fetchApplicationsVersionsWithRetry, setSettingUpFinished]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); useEffect(() => { if (adminShow === 'setup') return; @@ -75,5 +77,6 @@ export function useSetUp() { return () => { unlistenPromise.then((unlisten) => unlisten()); }; - }, [clearStorage, handlePostSetup, setCriticalError, setSetupDetails, adminShow, syncedAidropWithBackend]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [clearStorage, handlePostSetup, adminShow, syncedAidropWithBackend]); } diff --git a/src/hooks/helpers/useDetectMode.ts b/src/hooks/helpers/useDetectMode.ts index 826eaeaa3..8239363af 100644 --- a/src/hooks/helpers/useDetectMode.ts +++ b/src/hooks/helpers/useDetectMode.ts @@ -20,5 +20,6 @@ export function useDetectMode() { return () => { listener.then((unlisten) => unlisten()); }; - }, [setTheme, configTheme]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [configTheme]); } diff --git a/src/hooks/mining/useTransactions.ts b/src/hooks/mining/useTransactions.ts index e9bbb7686..ed81b00bd 100644 --- a/src/hooks/mining/useTransactions.ts +++ b/src/hooks/mining/useTransactions.ts @@ -16,7 +16,7 @@ export default function useFetchTx() { async (newTx: Transaction[]) => { const latestTx = newTx[0]; const latestId = latestTx?.tx_id; - const hasNewItems = !transactions?.find((tx) => tx.tx_id === latestId); + const hasNewItems = transactions?.find((tx) => tx.tx_id === latestId); if (hasNewItems) { setTransactions(newTx); } diff --git a/src/hooks/useListenForCriticalProblem.tsx b/src/hooks/useListenForCriticalProblem.tsx index a3b090360..ae54c0d51 100644 --- a/src/hooks/useListenForCriticalProblem.tsx +++ b/src/hooks/useListenForCriticalProblem.tsx @@ -13,7 +13,8 @@ const useListenForCriticalProblem = () => { return () => { unlistenPromise.then((unlisten) => unlisten()); }; - }, [setCriticalProblem]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); }; export default useListenForCriticalProblem; From 5fa881aaab38bedd8bd1a91c108cce94fa8a9eda Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 08:52:07 -0300 Subject: [PATCH 05/17] removes block height --- .../ShareRewardModal/ShareRewardModal.tsx | 10 ++++++---- .../SideBar/components/Wallet/HistoryItem.tsx | 15 +++++++++------ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx index bd3bbf566..654bc3620 100644 --- a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx +++ b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx @@ -9,7 +9,7 @@ import { RewardWrapper, Title, Value, - WinnerPill, + // WinnerPill, Number, Copied, GemPill, @@ -71,9 +71,11 @@ export default function ShareRewardModal() { {t('share.title')} - - {t('share.winner-pill')} #{block.toLocaleString()} - + { + // + // {t('share.winner-pill')} #{block.toLocaleString()} + // + } diff --git a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx index 12081197a..d8fb11aac 100644 --- a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx +++ b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx @@ -71,11 +71,11 @@ export default function HistoryItem({ item }: HistoryItemProps) { handleWinReplay(item); }, [handleWinReplay, item]); - if (!item.blockHeight || item.payment_id?.length > 0) { - return null; - } + // if (!item.blockHeight || item.payment_id?.length > 0) { + // return null; + // } - const itemTitle = `${t('block')} #${item.blockHeight}`; + const itemTitle = `${t('block')}`; const itemTime = new Date(item.timestamp * 1000)?.toLocaleString(systemLang ? undefined : appLanguage, { month: 'short', day: '2-digit', @@ -122,8 +122,11 @@ export default function HistoryItem({ item }: HistoryItemProps) { - {itemTitle} - {itemTime} + { + // {itemTitle} + // {itemTime} + } + {itemTime} From c058148bcd75e4319a7579de044860bb5d38b0f9 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 09:25:45 -0300 Subject: [PATCH 06/17] handles missing block height --- .../ShareRewardModal/ShareRewardModal.tsx | 12 ++++++------ .../SideBar/components/Wallet/HistoryItem.tsx | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx index 654bc3620..06c02ebbd 100644 --- a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx +++ b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx @@ -9,7 +9,7 @@ import { RewardWrapper, Title, Value, - // WinnerPill, + WinnerPill, Number, Copied, GemPill, @@ -71,11 +71,11 @@ export default function ShareRewardModal() { {t('share.title')} - { - // - // {t('share.winner-pill')} #{block.toLocaleString()} - // - } + {block ? ( + + {t('share.winner-pill')} #{block.toLocaleString()} + + ) : null} diff --git a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx index d8fb11aac..75f5b7205 100644 --- a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx +++ b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx @@ -75,7 +75,7 @@ export default function HistoryItem({ item }: HistoryItemProps) { // return null; // } - const itemTitle = `${t('block')}`; + const itemTitle = `${t('block')} #${item.blockHeight}`; const itemTime = new Date(item.timestamp * 1000)?.toLocaleString(systemLang ? undefined : appLanguage, { month: 'short', day: '2-digit', @@ -122,11 +122,14 @@ export default function HistoryItem({ item }: HistoryItemProps) { - { - // {itemTitle} - // {itemTime} - } - {itemTime} + {item.blockHeight ? ( + <> + {itemTitle} + {itemTime} + + ) : ( + {itemTime} + )} From 477e4d4403b42035d5b75a45bac047385cf02726 Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 23 Dec 2024 13:25:39 +0100 Subject: [PATCH 07/17] update grpc struct to handle new tari core versions --- src-tauri/Cargo.lock | 84 ++++++++++++++++----------------- src-tauri/Cargo.toml | 14 +++--- src-tauri/src/wallet_adapter.rs | 4 +- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 4afb0fe20..0209f89da 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3903,8 +3903,8 @@ dependencies = [ [[package]] name = "minotari_app_grpc" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "argon2", "base64 0.13.1", @@ -3933,8 +3933,8 @@ dependencies = [ [[package]] name = "minotari_ledger_wallet_common" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "bs58 0.5.1", ] @@ -3942,7 +3942,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "minotari_app_grpc", ] @@ -3950,7 +3950,7 @@ dependencies = [ [[package]] name = "minotari_wallet_grpc_client" version = "0.1.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "minotari_app_grpc", "tari_common_types", @@ -6993,8 +6993,8 @@ dependencies = [ [[package]] name = "tari_common" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "config", @@ -7017,8 +7017,8 @@ dependencies = [ [[package]] name = "tari_common_sqlite" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "diesel", "diesel_migrations", @@ -7031,8 +7031,8 @@ dependencies = [ [[package]] name = "tari_common_types" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -7057,8 +7057,8 @@ dependencies = [ [[package]] name = "tari_comms" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "async-trait", @@ -7101,8 +7101,8 @@ dependencies = [ [[package]] name = "tari_comms_dht" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -7136,8 +7136,8 @@ dependencies = [ [[package]] name = "tari_comms_rpc_macros" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "proc-macro2", "quote", @@ -7146,8 +7146,8 @@ dependencies = [ [[package]] name = "tari_core" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "async-trait", @@ -7240,13 +7240,13 @@ dependencies = [ [[package]] name = "tari_features" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" [[package]] name = "tari_hashing" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "borsh", "digest", @@ -7255,8 +7255,8 @@ dependencies = [ [[package]] name = "tari_key_manager" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "argon2", "async-trait", @@ -7288,8 +7288,8 @@ dependencies = [ [[package]] name = "tari_max_size" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "borsh", "serde", @@ -7299,8 +7299,8 @@ dependencies = [ [[package]] name = "tari_mmr" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "borsh", "digest", @@ -7313,8 +7313,8 @@ dependencies = [ [[package]] name = "tari_p2p" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "fs2", @@ -7345,8 +7345,8 @@ dependencies = [ [[package]] name = "tari_script" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "blake2", "borsh", @@ -7363,8 +7363,8 @@ dependencies = [ [[package]] name = "tari_service_framework" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "anyhow", "async-trait", @@ -7378,16 +7378,16 @@ dependencies = [ [[package]] name = "tari_shutdown" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "futures 0.3.31", ] [[package]] name = "tari_storage" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "bincode", "lmdb-zero", @@ -7398,8 +7398,8 @@ dependencies = [ [[package]] name = "tari_test_utils" -version = "1.9.1-pre.0" -source = "git+https://github.com/tari-project/tari.git?rev=37c30be#37c30be6bd6df026dc16eec5f4d8cfaf2225f9c6" +version = "1.9.1-rc.1" +source = "git+https://github.com/tari-project/tari.git?tag=v1.9.1-rc.1#65a61008a5f7c05c34453535894b9a24132d2665" dependencies = [ "futures 0.3.31", "rand 0.8.5", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6ab2d3133..786dec115 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -38,8 +38,8 @@ libsqlite3-sys = { version = "0.25.1", features = [ ] } # Required for tari_wallet log = "0.4.22" log4rs = "1.3.0" -minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } -minotari_wallet_grpc_client = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } +minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } +minotari_wallet_grpc_client = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } monero-address-creator = { git = "https://github.com/tari-project/monero-address-creator.git", rev = "6129ca0" } nix = { version = "0.29.0", features = ["signal"] } nvml-wrapper = "0.10.0" @@ -58,15 +58,15 @@ sha2 = "0.10.8" sys-locale = "0.3.1" sysinfo = "0.31.2" tar = "0.4.26" -tari_common = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } -tari_common_types = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } -tari_core = { git = "https://github.com/tari-project/tari.git", rev = "37c30be", features = [ +tari_common = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } +tari_common_types = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } +tari_core = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1", features = [ "transactions", ] } tauri-plugin-single-instance = { git = "https://github.com/tari-project/tauri-plugins-workspace", rev = "09f29b0abe2cb1eb81365b65a3aa3f73325e4e17" } tari_crypto = "0.21.0" -tari_key_manager = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } -tari_shutdown = { git = "https://github.com/tari-project/tari.git", rev = "37c30be" } +tari_key_manager = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } +tari_shutdown = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } tari_utilities = "0.8.0" tauri = { git = "https://github.com/tari-project/tauri.git", rev = "67a06c8a9bae94f412b8059dfa8b4d8dd8ea0a25", features = [ "macos-private-api", diff --git a/src-tauri/src/wallet_adapter.rs b/src-tauri/src/wallet_adapter.rs index 8029185fa..cdb8638d6 100644 --- a/src-tauri/src/wallet_adapter.rs +++ b/src-tauri/src/wallet_adapter.rs @@ -265,8 +265,8 @@ pub struct TransactionInfo { pub is_cancelled: bool, pub excess_sig: String, pub timestamp: u64, - pub message: String, pub payment_id: String, + pub mined_in_block_height: u64, } impl WalletStatusMonitor { @@ -324,8 +324,8 @@ impl WalletStatusMonitor { is_cancelled: tx.is_cancelled, excess_sig: tx.excess_sig.to_hex(), timestamp: tx.timestamp, - message: tx.message, payment_id: tx.payment_id.to_hex(), + mined_in_block_height: tx.mined_in_block_height, }); } Ok(transactions) From 3690857da9bf27319d9ba2735e6567c4d3df0190 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 09:33:11 -0300 Subject: [PATCH 08/17] handles new block height field --- src/hooks/mining/useTransactions.ts | 8 +------- src/types/app-status.ts | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/hooks/mining/useTransactions.ts b/src/hooks/mining/useTransactions.ts index ed81b00bd..f757f5233 100644 --- a/src/hooks/mining/useTransactions.ts +++ b/src/hooks/mining/useTransactions.ts @@ -33,13 +33,7 @@ export default function useFetchTx() { const txs = await invoke('get_transaction_history'); const sortedTransactions = txs.sort((a, b) => b.timestamp - a.timestamp); const mapped = sortedTransactions?.map((tx) => { - const blockHeight = tx.message.split(': ')[1]; - - if (blockHeight) { - return { ...tx, blockHeight }; - } - - return tx; + return { ...tx, blockHeight: tx.mined_in_block_height }; }) as Transaction[]; if (mapped?.length) { diff --git a/src/types/app-status.ts b/src/types/app-status.ts index 84737ed6d..79de36529 100644 --- a/src/types/app-status.ts +++ b/src/types/app-status.ts @@ -113,6 +113,7 @@ export interface TransactionInfo { timestamp: number; message: string; payment_id: string; + mined_in_block_height?: number; } export interface P2poolStatsResult { From 593730e4a1d406a6b9d18ecc507721580ab87020 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 09:46:47 -0300 Subject: [PATCH 09/17] fixes history --- .../ShareRewardModal/ShareRewardModal.tsx | 2 +- .../MiningView/components/Earnings.tsx | 4 ++-- .../SideBar/components/Wallet/HistoryItem.tsx | 12 ++++------ .../main/SideBar/components/Wallet/Wallet.tsx | 12 +++++----- src/hooks/mining/useTransactions.ts | 23 ++----------------- src/store/useBlockchainVisualisationStore.ts | 7 +++--- src/store/useShareRewardStore.ts | 6 ++--- src/store/useWalletStore.ts | 7 +++--- src/types/wallet.ts | 5 ---- 9 files changed, 24 insertions(+), 54 deletions(-) delete mode 100644 src/types/wallet.ts diff --git a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx index 06c02ebbd..340f191d3 100644 --- a/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx +++ b/src/containers/floating/ShareRewardModal/ShareRewardModal.tsx @@ -52,7 +52,7 @@ export default function ShareRewardModal() { const referralCode = userDetails?.user?.referral_code || ''; const gemsValue = (referralQuestPoints?.pointsForClaimingReferral || GIFT_GEMS).toLocaleString(); - const block = item?.blockHeight || 0; + const block = item?.mined_in_block_height || 0; const reward = item?.amount || 0; const earningsFormatted = useMemo(() => formatNumber(reward, FormatPreset.TXTM_COMPACT).toLowerCase(), [reward]); diff --git a/src/containers/main/Dashboard/MiningView/components/Earnings.tsx b/src/containers/main/Dashboard/MiningView/components/Earnings.tsx index 209465b30..3a86b70ff 100644 --- a/src/containers/main/Dashboard/MiningView/components/Earnings.tsx +++ b/src/containers/main/Dashboard/MiningView/components/Earnings.tsx @@ -52,13 +52,13 @@ export default function Earnings() { ) : null; const replayText = - replayItem?.amount && replayItem.blockHeight ? ( + replayItem?.amount && replayItem.mined_in_block_height ? ( }} /> diff --git a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx index 75f5b7205..55dd575af 100644 --- a/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx +++ b/src/containers/main/SideBar/components/Wallet/HistoryItem.tsx @@ -21,14 +21,14 @@ import { useCallback, useMemo, useState } from 'react'; import { AnimatePresence } from 'framer-motion'; import gemImage from '../../../Airdrop/AirdropGiftTracker/images/gem.png'; import { useShareRewardStore } from '@app/store/useShareRewardStore.ts'; -import { Transaction } from '@app/types/wallet.ts'; import { GIFT_GEMS, useAirdropStore } from '@app/store/useAirdropStore.ts'; import { useAppConfigStore } from '@app/store/useAppConfigStore.ts'; import { ReplaySVG } from '@app/assets/icons/replay'; import { formatNumber, FormatPreset } from '@app/utils/formatters.ts'; +import { TransactionInfo } from '@app/types/app-status.ts'; interface HistoryItemProps { - item: Transaction; + item: TransactionInfo; } const randomGradientColours = [ @@ -71,11 +71,7 @@ export default function HistoryItem({ item }: HistoryItemProps) { handleWinReplay(item); }, [handleWinReplay, item]); - // if (!item.blockHeight || item.payment_id?.length > 0) { - // return null; - // } - - const itemTitle = `${t('block')} #${item.blockHeight}`; + const itemTitle = `${t('block')} #${item.mined_in_block_height}`; const itemTime = new Date(item.timestamp * 1000)?.toLocaleString(systemLang ? undefined : appLanguage, { month: 'short', day: '2-digit', @@ -122,7 +118,7 @@ export default function HistoryItem({ item }: HistoryItemProps) { - {item.blockHeight ? ( + {item.mined_in_block_height ? ( <> {itemTitle} {itemTime} diff --git a/src/containers/main/SideBar/components/Wallet/Wallet.tsx b/src/containers/main/SideBar/components/Wallet/Wallet.tsx index 49d097ca3..1b3bb618c 100644 --- a/src/containers/main/SideBar/components/Wallet/Wallet.tsx +++ b/src/containers/main/SideBar/components/Wallet/Wallet.tsx @@ -63,12 +63,12 @@ export default function Wallet() { const displayValue = balance === null ? '-' : showBalance ? formatted : '*****'; const handleShowClick = useCallback(async () => { - // if (balance && !transactions.length && !isTransactionLoading) { - // await fetchTx(); - // } else { - // setRecapCount(undefined); - // } - await fetchTx(); + console.log({ balance, transactions, isTransactionLoading }); + if (balance && !transactions.length && !isTransactionLoading) { + await fetchTx(); + } else { + setRecapCount(undefined); + } setShowHistory((c) => !c); // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/hooks/mining/useTransactions.ts b/src/hooks/mining/useTransactions.ts index f757f5233..c92c89a56 100644 --- a/src/hooks/mining/useTransactions.ts +++ b/src/hooks/mining/useTransactions.ts @@ -3,28 +3,13 @@ import { useCallback } from 'react'; import { invoke } from '@tauri-apps/api/core'; import { useAppStateStore } from '@app/store/appStateStore.ts'; import { useWalletStore } from '@app/store/useWalletStore.ts'; -import { Transaction } from '@app/types/wallet.ts'; export default function useFetchTx() { - const transactions = useWalletStore((s) => s.transactions); const isTransactionLoading = useWalletStore((s) => s.isTransactionLoading); const setTransactionsLoading = useWalletStore((s) => s.setTransactionsLoading); const setupProgress = useAppStateStore((s) => s.setupProgress); const setTransactions = useWalletStore((s) => s.setTransactions); - const setItems = useCallback( - async (newTx: Transaction[]) => { - const latestTx = newTx[0]; - const latestId = latestTx?.tx_id; - const hasNewItems = transactions?.find((tx) => tx.tx_id === latestId); - if (hasNewItems) { - setTransactions(newTx); - } - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [transactions] - ); - return useCallback(async () => { if (isTransactionLoading || setupProgress < 0.75) return; setTransactionsLoading(true); @@ -32,12 +17,8 @@ export default function useFetchTx() { try { const txs = await invoke('get_transaction_history'); const sortedTransactions = txs.sort((a, b) => b.timestamp - a.timestamp); - const mapped = sortedTransactions?.map((tx) => { - return { ...tx, blockHeight: tx.mined_in_block_height }; - }) as Transaction[]; - - if (mapped?.length) { - await setItems(mapped); + if (sortedTransactions?.length) { + setTransactions(sortedTransactions); } setTransactionsLoading(false); } catch (error) { diff --git a/src/store/useBlockchainVisualisationStore.ts b/src/store/useBlockchainVisualisationStore.ts index c682c4cab..ce70b69db 100644 --- a/src/store/useBlockchainVisualisationStore.ts +++ b/src/store/useBlockchainVisualisationStore.ts @@ -1,4 +1,3 @@ -import { Transaction } from '@app/types/wallet'; import { create } from './create'; import { useMiningStore } from './useMiningStore.ts'; @@ -21,7 +20,7 @@ interface State { recapData?: Recap; recapCount?: number; recapIds: TransactionInfo['tx_id'][]; - replayItem?: Transaction; + replayItem?: TransactionInfo; } interface WinAnimation { @@ -32,7 +31,7 @@ interface WinAnimation { interface Actions { handleWin: ({ latestTx, canAnimate, isRecap }: WinAnimation) => Promise; handleWinRecap: (recapData: Recap) => void; - handleWinReplay: (txItem: Transaction) => void; + handleWinReplay: (txItem: TransactionInfo) => void; handleFail: (blockHeight: number, canAnimate?: boolean) => Promise; handleNewBlock: (newBlockHeight: number, isMining?: boolean) => Promise; setDisplayBlockHeight: (displayBlockHeight: number) => void; @@ -100,7 +99,7 @@ export const useBlockchainVisualisationStore = create { - const blockHeight = Number(latestTx?.message?.split(': ')[1]); + const blockHeight = Number(latestTx?.mined_in_block_height); const earnings = latestTx.amount; console.info(`Block #${blockHeight} mined! Earnings: ${earnings}`); diff --git a/src/store/useShareRewardStore.ts b/src/store/useShareRewardStore.ts index ffb15ffd6..4b5658fa3 100644 --- a/src/store/useShareRewardStore.ts +++ b/src/store/useShareRewardStore.ts @@ -1,14 +1,14 @@ +import { TransactionInfo } from '@app/types/app-status.ts'; import { create } from './create.ts'; -import { Transaction } from '@app/types/wallet.ts'; interface State { showModal: boolean; - item: Transaction | null; + item: TransactionInfo | null; } interface Actions { setShowModal: (showModal: boolean) => void; - setItemData: (item: Transaction | null) => void; + setItemData: (item: TransactionInfo | null) => void; } const initialState: State = { diff --git a/src/store/useWalletStore.ts b/src/store/useWalletStore.ts index c9e83eda8..c62b9005a 100644 --- a/src/store/useWalletStore.ts +++ b/src/store/useWalletStore.ts @@ -1,15 +1,14 @@ import { ALREADY_FETCHING } from '@app/App/sentryIgnore'; import { create } from './create'; -import { WalletBalance } from '../types/app-status.ts'; +import { TransactionInfo, WalletBalance } from '../types/app-status.ts'; import { invoke } from '@tauri-apps/api/core'; -import { Transaction } from '@app/types/wallet.ts'; interface State extends WalletBalance { tari_address_base58: string; tari_address_emoji: string; tari_address?: string; balance: number | null; - transactions: Transaction[]; + transactions: TransactionInfo[]; isTransactionLoading: boolean; is_wallet_importing: boolean; } @@ -17,7 +16,7 @@ interface State extends WalletBalance { interface Actions { fetchWalletDetails: () => Promise; setTransactionsLoading: (isTransactionLoading: boolean) => void; - setTransactions: (transactions?: Transaction[]) => void; + setTransactions: (transactions?: TransactionInfo[]) => void; importSeedWords: (seedWords: string[]) => Promise; } diff --git a/src/types/wallet.ts b/src/types/wallet.ts deleted file mode 100644 index 278266184..000000000 --- a/src/types/wallet.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { TransactionInfo } from '@app/types/app-status.ts'; - -export interface Transaction extends TransactionInfo { - blockHeight?: number; -} From 4723cd20730de1d01c11bd1522c4ff2e7973f3d3 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 10:08:38 -0300 Subject: [PATCH 10/17] update --- src/hooks/mining/useMiningMetricsUpdater.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/hooks/mining/useMiningMetricsUpdater.ts b/src/hooks/mining/useMiningMetricsUpdater.ts index 128f0193e..d60cd6693 100644 --- a/src/hooks/mining/useMiningMetricsUpdater.ts +++ b/src/hooks/mining/useMiningMetricsUpdater.ts @@ -48,14 +48,7 @@ export default function useMiningMetricsUpdater() { setMiningMetrics(metrics); } }, - [ - baseNodeConnected, - currentBlockHeight, - displayBlockHeight, - fetchTx, - handleNewBlock, - setDisplayBlockHeight, - setMiningMetrics, - ] + // eslint-disable-next-line react-hooks/exhaustive-deps + [baseNodeConnected, currentBlockHeight, displayBlockHeight, fetchTx] ); } From 25544099e29203adac8bf77d328858784ed39088 Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 23 Dec 2024 14:27:10 +0100 Subject: [PATCH 11/17] taplo fix --- src-tauri/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 786dec115..591b3019c 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -58,7 +58,7 @@ sha2 = "0.10.8" sys-locale = "0.3.1" sysinfo = "0.31.2" tar = "0.4.26" -tari_common = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } +tari_common = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } tari_common_types = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1" } tari_core = { git = "https://github.com/tari-project/tari.git", tag = "v1.9.1-rc.1", features = [ "transactions", From f0109b5a5cb30d61be602f3519e6f6aa778285ce Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 11:11:26 -0300 Subject: [PATCH 12/17] prevent unneded store updates --- .../useAirdropUserPointsListener.ts | 8 ++++++-- src/hooks/mining/useMiningStatesSync.ts | 12 +++++++++--- src/store/useBlockchainVisualisationStore.ts | 1 + src/utils/objectDeepEqual.ts | 19 +++++++++++++++++++ 4 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 src/utils/objectDeepEqual.ts diff --git a/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts b/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts index 7995a9a72..7810f93e7 100644 --- a/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts +++ b/src/hooks/airdrop/stateHelpers/useAirdropUserPointsListener.ts @@ -1,12 +1,14 @@ import { useAirdropStore, UserPoints } from '@app/store/useAirdropStore'; +import { deepEqual } from '@app/utils/objectDeepEqual'; import { listen } from '@tauri-apps/api/event'; -import { useCallback, useEffect } from 'react'; +import { useCallback, useEffect, useRef } from 'react'; export const useAirdropUserPointsListener = () => { const setUserPoints = useAirdropStore((state) => state?.setUserPoints); const currentReferralData = useAirdropStore((state) => state?.referralCount); const bonusTiers = useAirdropStore((state) => state.bonusTiers); const setFlareAnimationType = useAirdropStore((state) => state.setFlareAnimationType); + const cachedUserPoints = useRef(); const handleAirdropPoints = useCallback( (pointsPayload: UserPoints) => { @@ -28,7 +30,9 @@ export const useAirdropUserPointsListener = () => { useEffect(() => { const ul = listen('UserPoints', ({ payload }) => { - if (payload) { + if (!payload) return; + const payloadChanged = !deepEqual(payload as UserPoints, cachedUserPoints.current); + if (payloadChanged) { handleAirdropPoints(payload as UserPoints); } }); diff --git a/src/hooks/mining/useMiningStatesSync.ts b/src/hooks/mining/useMiningStatesSync.ts index 360301b98..3bf9b8ef3 100644 --- a/src/hooks/mining/useMiningStatesSync.ts +++ b/src/hooks/mining/useMiningStatesSync.ts @@ -1,6 +1,6 @@ import { MinerMetrics } from '@app/types/app-status'; import { listen } from '@tauri-apps/api/event'; -import { useEffect } from 'react'; +import { useEffect, useRef } from 'react'; import { useWalletStore } from '@app/store/useWalletStore.ts'; import { useAppStateStore } from '@app/store/appStateStore'; @@ -9,12 +9,14 @@ import { useBlockInfo } from './useBlockInfo.ts'; import { useUiMiningStateMachine } from './useMiningUiStateMachine.ts'; import useMiningMetricsUpdater from './useMiningMetricsUpdater.ts'; import useEarningsRecap from './useEarningsRecap.ts'; +import { deepEqual } from '@app/utils/objectDeepEqual.ts'; export function useMiningStatesSync() { const handleMiningMetrics = useMiningMetricsUpdater(); const fetchWalletDetails = useWalletStore((s) => s.fetchWalletDetails); const setupProgress = useAppStateStore((s) => s.setupProgress); const isSettingUp = useAppStateStore((s) => s.isSettingUp); + const prevPayload = useRef(); useBlockInfo(); useUiMiningStateMachine(); @@ -33,12 +35,16 @@ export function useMiningStatesSync() { useEffect(() => { if (isSettingUp) return; const ul = listen('miner_metrics', async ({ payload }) => { - if (payload) { + if (!payload) return; + const payloadChanged = !deepEqual(payload as MinerMetrics, prevPayload.current); + if (payloadChanged) { + prevPayload.current = payload as MinerMetrics; await handleMiningMetrics(payload as MinerMetrics); } }); return () => { ul.then((unlisten) => unlisten()); }; - }, [handleMiningMetrics, isSettingUp]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isSettingUp]); } diff --git a/src/store/useBlockchainVisualisationStore.ts b/src/store/useBlockchainVisualisationStore.ts index ce70b69db..919c58966 100644 --- a/src/store/useBlockchainVisualisationStore.ts +++ b/src/store/useBlockchainVisualisationStore.ts @@ -43,6 +43,7 @@ interface Actions { type BlockchainVisualisationStoreState = State & Actions; const checkCanAnimate = async () => { + console.log('checkCanAnimate'); const focused = await appWindow?.isFocused(); const minimized = await appWindow?.isMinimized(); const documentIsVisible = document?.visibilityState === 'visible' || false; diff --git a/src/utils/objectDeepEqual.ts b/src/utils/objectDeepEqual.ts new file mode 100644 index 000000000..bd771a663 --- /dev/null +++ b/src/utils/objectDeepEqual.ts @@ -0,0 +1,19 @@ +export function deepEqual(obj1: unknown, obj2: unknown) { + if (obj1 === obj2) return true; + if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 == null || obj2 == null) { + return false; + } + + const keys1 = Object.keys(obj1); + const keys2 = Object.keys(obj2); + + if (keys1.length !== keys2.length) return false; + + for (const key of keys1) { + if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) { + return false; + } + } + + return true; +} From 90a1c59ccb7b38bf5a0534d50ac015191c978eb9 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 12:05:59 -0300 Subject: [PATCH 13/17] update in minimized --- src/hooks/mining/useEarningsRecap.ts | 23 ++++++++++++++------ src/store/useBlockchainVisualisationStore.ts | 1 - src/utils/debounce.ts | 8 +++++++ 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 src/utils/debounce.ts diff --git a/src/hooks/mining/useEarningsRecap.ts b/src/hooks/mining/useEarningsRecap.ts index 96aae9d13..1ed3a3b3e 100644 --- a/src/hooks/mining/useEarningsRecap.ts +++ b/src/hooks/mining/useEarningsRecap.ts @@ -3,6 +3,7 @@ import { useCallback, useEffect } from 'react'; import { listen } from '@tauri-apps/api/event'; import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'; import { useWalletStore } from '@app/store/useWalletStore.ts'; +import { debounce } from '@app/utils/debounce'; const appWindow = getCurrentWebviewWindow(); export default function useEarningsRecap() { @@ -20,17 +21,25 @@ export default function useEarningsRecap() { handleWinRecap({ count, totalEarnings }); } } - }, [handleWinRecap, recapIds, transactions]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [recapIds, transactions]); useEffect(() => { + // Debounced function to check if the window is minimized + const debouncedIsMinimized = debounce(async () => { + console.log('Checking if window is minimized'); + const minimized = await appWindow?.isMinimized(); + const documentIsVisible = document?.visibilityState === 'visible' || false; + if (documentIsVisible && !minimized) { + getMissedEarnings(); + } + }, 1000); // 1 second debounce + const listener = listen( 'tauri://focus', - async () => { - const minimized = await appWindow?.isMinimized(); - const documentIsVisible = document?.visibilityState === 'visible' || false; - if (documentIsVisible && !minimized) { - getMissedEarnings(); - } + () => { + console.log('Focus event received'); + debouncedIsMinimized(); }, { target: { kind: 'WebviewWindow', label: 'main' } } ); diff --git a/src/store/useBlockchainVisualisationStore.ts b/src/store/useBlockchainVisualisationStore.ts index 919c58966..ce70b69db 100644 --- a/src/store/useBlockchainVisualisationStore.ts +++ b/src/store/useBlockchainVisualisationStore.ts @@ -43,7 +43,6 @@ interface Actions { type BlockchainVisualisationStoreState = State & Actions; const checkCanAnimate = async () => { - console.log('checkCanAnimate'); const focused = await appWindow?.isFocused(); const minimized = await appWindow?.isMinimized(); const documentIsVisible = document?.visibilityState === 'visible' || false; diff --git a/src/utils/debounce.ts b/src/utils/debounce.ts new file mode 100644 index 000000000..2d745f534 --- /dev/null +++ b/src/utils/debounce.ts @@ -0,0 +1,8 @@ +// Custom debounce function +export function debounce(func: (...args: unknown[]) => void, wait: number) { + let timeout: NodeJS.Timeout; + return (...args: unknown[]) => { + clearTimeout(timeout); + timeout = setTimeout(() => func(...args), wait); + }; +} From f9eac7a063cdf00744148eabf6171f7b2c7ffd82 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 13:01:10 -0300 Subject: [PATCH 14/17] removes console log --- src/containers/main/SideBar/components/Wallet/Wallet.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/containers/main/SideBar/components/Wallet/Wallet.tsx b/src/containers/main/SideBar/components/Wallet/Wallet.tsx index 1b3bb618c..3881ea67b 100644 --- a/src/containers/main/SideBar/components/Wallet/Wallet.tsx +++ b/src/containers/main/SideBar/components/Wallet/Wallet.tsx @@ -63,7 +63,6 @@ export default function Wallet() { const displayValue = balance === null ? '-' : showBalance ? formatted : '*****'; const handleShowClick = useCallback(async () => { - console.log({ balance, transactions, isTransactionLoading }); if (balance && !transactions.length && !isTransactionLoading) { await fetchTx(); } else { From d898390729f17f6e289a636495edc501fdb20cd9 Mon Sep 17 00:00:00 2001 From: Juan De Luca Date: Mon, 23 Dec 2024 13:01:46 -0300 Subject: [PATCH 15/17] removes more logs --- src/hooks/mining/useEarningsRecap.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hooks/mining/useEarningsRecap.ts b/src/hooks/mining/useEarningsRecap.ts index 1ed3a3b3e..a4b5d3652 100644 --- a/src/hooks/mining/useEarningsRecap.ts +++ b/src/hooks/mining/useEarningsRecap.ts @@ -27,7 +27,6 @@ export default function useEarningsRecap() { useEffect(() => { // Debounced function to check if the window is minimized const debouncedIsMinimized = debounce(async () => { - console.log('Checking if window is minimized'); const minimized = await appWindow?.isMinimized(); const documentIsVisible = document?.visibilityState === 'visible' || false; if (documentIsVisible && !minimized) { @@ -38,7 +37,6 @@ export default function useEarningsRecap() { const listener = listen( 'tauri://focus', () => { - console.log('Focus event received'); debouncedIsMinimized(); }, { target: { kind: 'WebviewWindow', label: 'main' } } From 8a22b3a00aa7cf427109c4981ac8679e3d23f4c0 Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 23 Dec 2024 17:42:32 +0100 Subject: [PATCH 16/17] fix gpu status on stop --- src-tauri/src/gpu_miner.rs | 1 + src-tauri/src/gpu_miner_adapter.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/gpu_miner.rs b/src-tauri/src/gpu_miner.rs index 28e40e4da..41282b786 100644 --- a/src-tauri/src/gpu_miner.rs +++ b/src-tauri/src/gpu_miner.rs @@ -120,6 +120,7 @@ impl GpuMiner { pub async fn stop(&self) -> Result<(), anyhow::Error> { info!(target: LOG_TARGET, "Stopping xtrgpuminer"); let mut process_watcher = self.watcher.write().await; + let _res = process_watcher.adapter.latest_status_broadcast.send(GpuMinerStatus { is_mining: false, ..GpuMinerStatus::default() }); process_watcher.status_monitor = None; process_watcher.stop().await?; info!(target: LOG_TARGET, "xtrgpuminer stopped"); diff --git a/src-tauri/src/gpu_miner_adapter.rs b/src-tauri/src/gpu_miner_adapter.rs index 31b13e86d..0ebe91dce 100644 --- a/src-tauri/src/gpu_miner_adapter.rs +++ b/src-tauri/src/gpu_miner_adapter.rs @@ -61,7 +61,7 @@ pub(crate) struct GpuMinerAdapter { pub(crate) coinbase_extra: String, pub(crate) excluded_gpu_devices: Vec, pub(crate) gpu_devices: Vec, - latest_status_broadcast: watch::Sender, + pub(crate) latest_status_broadcast: watch::Sender, } impl GpuMinerAdapter { From efa473e00d4194081fd0dee5ed55fe999e6fa920 Mon Sep 17 00:00:00 2001 From: brianp Date: Mon, 23 Dec 2024 17:51:06 +0100 Subject: [PATCH 17/17] clippy --- src-tauri/src/gpu_miner.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/gpu_miner.rs b/src-tauri/src/gpu_miner.rs index 41282b786..6aa518af0 100644 --- a/src-tauri/src/gpu_miner.rs +++ b/src-tauri/src/gpu_miner.rs @@ -120,7 +120,13 @@ impl GpuMiner { pub async fn stop(&self) -> Result<(), anyhow::Error> { info!(target: LOG_TARGET, "Stopping xtrgpuminer"); let mut process_watcher = self.watcher.write().await; - let _res = process_watcher.adapter.latest_status_broadcast.send(GpuMinerStatus { is_mining: false, ..GpuMinerStatus::default() }); + let _res = process_watcher + .adapter + .latest_status_broadcast + .send(GpuMinerStatus { + is_mining: false, + ..GpuMinerStatus::default() + }); process_watcher.status_monitor = None; process_watcher.stop().await?; info!(target: LOG_TARGET, "xtrgpuminer stopped");