Skip to content

Commit

Permalink
fix keep changes button in modal
Browse files Browse the repository at this point in the history
  • Loading branch information
peps committed Jan 15, 2025
1 parent 45d2345 commit e539d41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DialogContent, Dialog } from '@app/components/elements/dialog/Dialog';
import { useCallback, useEffect, useState } from 'react';
import { ButtonWrapper, CountdownNumber, KeepButton, RevertButton, Text, TextWrapper, Title, Wrapper } from './styles';
import { useTranslation } from 'react-i18next';
import { useMiningStore } from '@app/store/useMiningStore';
import { changeMiningMode } from '@app/store/miningStoreActions.ts';

function Countdown({ onComplete }: { onComplete: () => void }) {
const [count, setCount] = useState(30);
Expand All @@ -25,7 +25,6 @@ export default function LudicrousCofirmationDialog() {
const { t } = useTranslation('components', { useSuspense: false });
const open = useUIStore((s) => s.dialogToShow === 'ludicrousConfirmation');
const setDialogToShow = useUIStore((s) => s.setDialogToShow);
const changeMiningMode = useMiningStore((s) => s.changeMiningMode);

const handleClose = useCallback(() => {
setDialogToShow(null);
Expand All @@ -34,7 +33,7 @@ export default function LudicrousCofirmationDialog() {
const handleChange = useCallback(async () => {
await changeMiningMode({ mode: 'Ludicrous' });
setDialogToShow(null);
}, [changeMiningMode, setDialogToShow]);
}, [setDialogToShow]);

return (
<Dialog open={open} onOpenChange={handleClose}>
Expand Down
8 changes: 7 additions & 1 deletion src/containers/main/SideBar/Miner/components/ModeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { modeType } from '@app/store/types';
import { CustomPowerLevelsDialogContainer } from './CustomPowerLevels/CustomPowerLevelsDialogContainer';
import { useMiningMetricsStore } from '@app/store/useMiningMetricsStore.ts';
import { changeMiningMode } from '@app/store/miningStoreActions.ts';
import { useUIStore } from '@app/store/useUIStore';

function ModeSelect() {
const { t } = useTranslation('common', { useSuspense: false });
Expand All @@ -28,16 +29,21 @@ function ModeSelect() {
const isMining = isCPUMining || isGPUMining;
const isMiningLoading = (isMining && !isMiningInitiated) || (isMiningInitiated && !isMining);
const custom_power_levels_enabled = useAppConfigStore((s) => s.custom_power_levels_enabled);
const setDialogToShow = useUIStore((s) => s.setDialogToShow);

const handleChange = useCallback(
async (newMode: string) => {
if (newMode === 'Custom') {
setCustomLevelsDialog(true);
return;
}
if (newMode === 'Ludicrous') {
setDialogToShow('ludicrousConfirmation');
return;
}
await changeMiningMode({ mode: newMode as modeType });
},
[setCustomLevelsDialog]
[setCustomLevelsDialog, setDialogToShow]
);

const tabOptions = useMemo(() => {
Expand Down

0 comments on commit e539d41

Please sign in to comment.