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 remove rounds
consolidate game and instance consolidate game and instance
do not allow vbox actions for finished instances
cause of logging
*SERVER* *SERVER*
* std game mode * std game mode

View File

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

View File

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

View File

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

View File

@ -11,6 +11,8 @@ function registerEvents(store) {
store.subscribe(() => { store.subscribe(() => {
const { game, instance, constructs, ws } = store.getState(); const { game, instance, constructs, ws } = store.getState();
if (!ws) return true;
if (!game) ws.clearGameStateTimeout(); if (!game) ws.clearGameStateTimeout();
if (!instance) ws.clearInstanceStateTimeout(); if (!instance) ws.clearInstanceStateTimeout();
}); });
@ -19,6 +21,15 @@ function registerEvents(store) {
store.dispatch(actions.setPing(ping)); 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) { function setConstructs(constructs) {
console.log('EVENT ->', 'constructs', 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 { return {
errorPrompt, errorPrompt,
clearCombiner, clearCombiner,