Save score in IndexedDB

This commit is contained in:
2024-02-18 15:17:23 +01:00
parent 8219634b9c
commit 2b29a8e4b2
6 changed files with 69 additions and 6 deletions
+3
View File
@@ -11,6 +11,7 @@ import Clock from '../../../assets/clock';
import '../styles.scss';
import { useRecoilState } from 'recoil';
import { gameStateAtom } from '../../../contexts/gameState';
import { saveToLocalStorage } from '../../../utils/generics';
// ---------------------------------------------------------------------------------------------------------------------
const Timer = () => {
@@ -53,7 +54,9 @@ const Timer = () => {
...prev,
gameTime: displayedTime,
}));
clearInterval(intervalId);
saveToLocalStorage(displayedTime);
}
}, [intervalId, gameState.endType, setGameState, displayedTime]);