Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
fixed history bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lochungtin committed Jun 1, 2021
1 parent a38a14d commit 5869ba3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecordType>,
}
Expand Down Expand Up @@ -57,7 +59,8 @@ class BoardView extends React.Component<ReduxProps> {
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);
Expand Down Expand Up @@ -109,6 +112,7 @@ class BoardView extends React.Component<ReduxProps> {
const mapStateToProps = state => ({
colortheme: state.colortheme,
game: state.game,
history: state.history,
records: state.records,
});

Expand Down

0 comments on commit 5869ba3

Please sign in to comment.