request account state when instance finished, remove account instances from socket

This commit is contained in:
Mashy
2019-09-12 15:24:16 +10:00
parent 075880d5a7
commit c82fb404d1
4 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ function Collection(args) {
teamSelect[insert] = id;
return setTeam(teamSelect);
}
console.log(constructs.length);
const dispConstructs = constructs.length >= ((teamPage + 1) * 6)
? constructs.slice(teamPage * 6, (teamPage + 1) * 6)
: constructs.slice(teamPage * 6, constructs.length);
+3 -2
View File
@@ -11,8 +11,8 @@ const Bottom = require('./main.bottom');
const addState = connect(
state => {
const { game, instance, account, nav } = state;
return { game, instance, account, nav };
const { game, instance, account, nav, ws } = state;
return { game, instance, account, nav, ws };
}
);
@@ -22,6 +22,7 @@ function Main(props) {
instance,
account,
nav,
ws,
} = props;
if (!account) {
+6 -2
View File
@@ -169,7 +169,7 @@ function registerEvents(store) {
}
function setInstance(v) {
const { account, instance } = store.getState();
const { account, instance, ws } = store.getState();
if (v) {
const player = v.players.find(p => p.id === account.id);
store.dispatch(actions.setPlayer(player));
@@ -180,7 +180,11 @@ function registerEvents(store) {
store.dispatch(actions.setActiveConstruct(first));
}
}
if (v.phase === 'Finished') setGame(null);
if (v.phase === 'Finished') {
setGame(null);
ws.sendAccountState();
}
return store.dispatch(actions.setInstance(v));
}
+3 -3
View File
@@ -43,8 +43,8 @@ function createSocket(events) {
send(['AccountConstructs', {}]);
}
function sendAccountInstances() {
send(['AccountInstances', {}]);
function sendAccountState() {
send(['AccountState', {}]);
}
function sendAccountSetTeam(ids) {
@@ -323,7 +323,7 @@ function createSocket(events) {
return {
sendAccountConstructs,
sendAccountInstances,
sendAccountState,
sendAccountSetTeam,