navto fetches instance list

This commit is contained in:
ntr 2019-05-29 18:15:11 +10:00
parent cb49552927
commit 18f580f9aa

View File

@ -23,6 +23,10 @@ const addState = connect(
return ws.sendInstanceState(instance.id); return ws.sendInstanceState(instance.id);
} }
function sendAccountInstances() {
return ws.sendAccountInstances();
}
return { return {
account, account,
instances, instances,
@ -30,6 +34,7 @@ const addState = connect(
constructs, constructs,
game, game,
sendInstanceState, sendInstanceState,
sendAccountInstances,
}; };
}, },
function receiveDispatch(dispatch) { function receiveDispatch(dispatch) {
@ -41,7 +46,7 @@ const addState = connect(
return dispatch(actions.setInstance(testInstance(id))); return dispatch(actions.setInstance(testInstance(id)));
} }
function navTo(place) { function setNav(place) {
dispatch(actions.setGame(null)); dispatch(actions.setGame(null));
dispatch(actions.setInstance(null)); dispatch(actions.setInstance(null));
return dispatch(actions.setNav(place)); return dispatch(actions.setNav(place));
@ -50,7 +55,7 @@ const addState = connect(
return { return {
setTestGame, setTestGame,
setTestInstance, setTestInstance,
navTo, setNav,
}; };
} }
); );
@ -59,16 +64,23 @@ function Nav(args) {
const { const {
account, account,
sendInstanceState, sendInstanceState,
sendAccountInstances,
team, team,
constructs, constructs,
instances, instances,
game, game,
navTo,
setTestGame, setTestGame,
setTestInstance, setTestInstance,
setNav,
} = args; } = args;
function navTo(p) {
if (p === 'list') sendAccountInstances();
return setNav(p);
}
function joinInstance(i) { function joinInstance(i) {
if (game) navTo(null); if (game) navTo(null);
sendInstanceState(i); sendInstanceState(i);