Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: p2p settings crash #1298

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useEffect, useState } from 'react';
import { CardComponent } from '@app/containers/floating/Settings/components/Card.component.tsx';

export default function P2PConnectionData() {
const { t } = useTranslation('p2p');
const { t } = useTranslation('p2p', { useSuspense: false });
const [copiedId, setCopiedId] = useState<string>();
const { copyToClipboard } = useCopyToClipboard();

Expand Down
9 changes: 5 additions & 4 deletions src/containers/floating/Settings/sections/p2p/P2PoolStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ const P2PoolStats = () => {
const fetchP2poolConnections = useP2poolStatsStore((s) => s?.fetchP2poolConnections);

useEffect(() => {
const fetchP2pStatsInterval = setInterval(async () => {
const handleFetchP2pStats = async () => {
await fetchP2pStats?.();
await fetchP2poolConnections?.();
}, 5000);

};
handleFetchP2pStats();
const fetchP2pStatsInterval = setInterval(handleFetchP2pStats, 5000);
return () => {
clearInterval(fetchP2pStatsInterval);
};
Expand All @@ -43,7 +44,7 @@ const P2PoolStats = () => {
const sha3Height = sha3Stats?.height;
const randomXHeight = randomXStats?.height;
return peers?.map((peer) => {
const { current_sha3x_height, current_random_x_height } = peer.peer_info || {};
const { current_sha3x_height, current_random_x_height } = peer?.peer_info || {};
const sha3Diff = sha3Height ? sha3Height - current_sha3x_height : undefined;
const randomxDiff = randomXHeight ? randomXHeight - current_random_x_height : undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const P2pMarkup = ({ setDisabledStats }: P2pMarkupProps) => {

const handleP2poolEnabled = useCallback(
async (event: React.ChangeEvent<HTMLInputElement>) => {
setDisabledStats(true);
await setP2poolEnabled(event.target.checked);
setDisabledStats(!event.target.checked);
setDialogToShow('restart');
},
[setDialogToShow, setDisabledStats, setP2poolEnabled]
Expand Down
Loading