You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1013 B

import * as WelcomeActions from '../../actions/welcome/welcome.actions';
import * as ModeActions from '../../actions/mode.actions';
import SETTINGS from '../../AppSettings';
let dispatch;
const emptyScores = JSON.stringify([
{ initials: "AAA", score: "0" },
{ initials: "AAA", score: "0" },
{ initials: "AAA", score: "0" },
{ initials: "AAA", score: "0" },
{ initials: "AAA", score: "0" },
]);
const WelcomeCtrl = {
setDispatch: (d) => dispatch = d,
// Note: If storage has not been set, it will be populated here with empty scores.
updateFromLocalStorage: () => {
const scores = JSON.parse(localStorage.getItem(SETTINGS.LOCAL_STORAGE_KEY) || emptyScores);
localStorage.setItem(SETTINGS.LOCAL_STORAGE_KEY, JSON.stringify(scores));
dispatch(WelcomeActions.updateScores(scores));
},
keydown: (e) => {
if (e.keyCode === 32 || e.keyCode === 13) {
dispatch(ModeActions.options());
}
}
};
export default WelcomeCtrl;