From 5869ba393be00cbce5cf9cebfc5f896e67344435 Mon Sep 17 00:00:00 2001 From: lochungtin Date: Tue, 1 Jun 2021 02:42:57 +0100 Subject: [PATCH] fixed history bug --- src/components/Board/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Board/index.tsx b/src/components/Board/index.tsx index d03d4aa..4acff13 100644 --- a/src/components/Board/index.tsx +++ b/src/components/Board/index.tsx @@ -14,9 +14,11 @@ import { updateGame, updateHistory, updateRecords, } from '../../redux/action'; import { keygen } from '../../utils/keygen'; import { Direction } from '../../utils/enums'; import { ColorSchemeType, GameConfig, RecordType, } from '../../utils/types'; +import { compare } from '../../utils/array'; interface ReduxProps { colortheme: ColorSchemeType, + history: GameConfig, game: GameConfig, records: Array, } @@ -57,7 +59,8 @@ class BoardView extends React.Component { let temp = { ...this.props.game }; // update history - store.dispatch(updateHistory({ ...temp })); + if (!compare(this.props.history.board, temp.board)) + store.dispatch(updateHistory({ ...temp })); // perform swipe Board.swipe(temp, direction); @@ -109,6 +112,7 @@ class BoardView extends React.Component { const mapStateToProps = state => ({ colortheme: state.colortheme, game: state.game, + history: state.history, records: state.records, });