store team in localstorage

This commit is contained in:
ntr 2019-06-05 16:48:59 +10:00
parent 9a9e7c9872
commit 211c2396bd
5 changed files with 27 additions and 4 deletions

View File

@ -46,6 +46,9 @@ locaalstorage team
remove rounds
consolidate game and instance
do not allow vbox actions for finished instances
cause of logging
*SERVER*
* std game mode

View File

@ -24,7 +24,7 @@ const addState = connect(
}
function sendInstanceList() {
return ws.sendAccountInstances();
return ws.sendInstanceList();
}
return {

View File

@ -10,8 +10,8 @@ const List = require('./list');
const addState = connect(
state => {
const { game, instance, account, nav } = state;
return { game, instance, account, nav };
const { game, instance, account, nav, team } = state;
return { game, instance, account, nav, team };
}
);
@ -21,6 +21,7 @@ function Main(props) {
instance,
account,
nav,
team,
} = props;
if (!account) {
@ -35,8 +36,8 @@ function Main(props) {
return <Instance />;
}
if (nav === 'team') return <Team />;
if (nav === 'list') return <List />;
if (nav === 'team' || !team.some(t => t)) return <Team />;
return (
<main></main>

View File

@ -27,6 +27,7 @@ const addState = connect(
function receiveDispatch(dispatch) {
function setTeam(constructIds) {
localStorage.setItem('team', JSON.stringify(constructIds));
dispatch(actions.setTeam(constructIds));
}

View File

@ -11,6 +11,8 @@ function registerEvents(store) {
store.subscribe(() => {
const { game, instance, constructs, ws } = store.getState();
if (!ws) return true;
if (!game) ws.clearGameStateTimeout();
if (!instance) ws.clearInstanceStateTimeout();
});
@ -19,6 +21,15 @@ function registerEvents(store) {
store.dispatch(actions.setPing(ping));
}
function setTeam(team) {
localStorage.setItem('team', JSON.stringify(team));
store.dispatch(actions.setTeam(team));
}
function setNav(v) {
store.dispatch(actions.setNav(v));
}
function setConstructs(constructs) {
console.log('EVENT ->', 'constructs', constructs);
}
@ -190,6 +201,13 @@ function registerEvents(store) {
});
}
// setup / localstorage
const team = JSON.parse(localStorage.getItem('team'));
if (team && team.every(t => t)) {
setTeam(team);
setNav('list');
}
return {
errorPrompt,
clearCombiner,