cleaning up methods added for sending and receiveing changed pronouns in sockets.js

This commit is contained in:
Dave 2021-03-02 19:16:46 +00:00
parent 77e89f290b
commit 992841a45b
1 changed files with 14 additions and 14 deletions

View File

@ -495,7 +495,7 @@ class LiveSession {
if (this._isSpectator && this._store.state.session.playerId !== player.id) if (this._isSpectator && this._store.state.session.playerId !== player.id)
return; return;
const index = this._store.state.players.players.indexOf(player); const index = this._store.state.players.players.indexOf(player);
this._send("pronouns", { index, value, fromST: !this._isSpectator }); this._send("pronouns", [index, value, !this._isSpectator]);
} }
/** /**
@ -505,19 +505,19 @@ class LiveSession {
* @param fromSt * @param fromSt
* @private * @private
*/ */
_updatePlayerPronouns({ index, value, fromST }) { _updatePlayerPronouns([index, value, fromST]) {
const player = this._store.state.players.players[index]; const player = this._store.state.players.players[index];
if ( if (
!player || player &&
(!fromST && this._store.state.session.playerId === player.id) || (fromST || this._store.state.session.playerId !== player.id) &&
player.pronouns === value player.pronouns !== value
) ) {
return; this._store.commit("players/update", {
this._store.commit("players/update", { player,
player, property: "pronouns",
property: "pronouns", value
value });
}); }
} }
/** /**
@ -851,9 +851,9 @@ export default store => {
case "players/update": case "players/update":
if (payload.property === "pronouns") { if (payload.property === "pronouns") {
session.sendPlayerPronouns(payload); session.sendPlayerPronouns(payload);
break; } else {
session.sendPlayer(payload);
} }
session.sendPlayer(payload);
break; break;
} }
}); });