diff --git a/src/components/Menu.vue b/src/components/Menu.vue index fc212a9..bbefe27 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -343,9 +343,6 @@ export default { this.$store.dispatch("players/clearRoles"); } }, - toggleRecordVoteHistory() { - this.$store.commit("session/toggleRecordVoteHistory"); - }, clearVoteHistory() { this.$store.commit("session/clearVoteHistory"); }, @@ -355,6 +352,7 @@ export default { "toggleImageOptIn", "toggleMuted", "toggleNight", + "toggleRecordVoteHistory", "toggleNightOrder", "setZoom", "toggleModal" diff --git a/src/components/Vote.vue b/src/components/Vote.vue index 50a8ca8..4bdd242 100644 --- a/src/components/Vote.vue +++ b/src/components/Vote.vue @@ -220,9 +220,7 @@ export default { }, finish() { clearInterval(this.voteTimer); - if (this.session.recordVoteHistory) { - this.$store.commit("session/addHistory", this.players); - } + this.$store.commit("session/addHistory", this.players); this.$store.commit("session/nomination"); }, vote(vote) { diff --git a/src/store/index.js b/src/store/index.js index 06a03be..d607754 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -78,6 +78,7 @@ export default new Vuex.Store({ state: { grimoire: { isNight: false, + recordVoteHistory: true, isNightOrder: true, isPublic: true, isMenuOpen: false, @@ -147,6 +148,13 @@ export default new Vuex.Store({ toggleNight: toggle("isNight"), toggleGrimoire: toggle("isPublic"), toggleImageOptIn: toggle("isImageOptIn"), + toggleRecordVoteHistory(state, param) { + if (param === true || param === false) { + state.session.recordVoteHistory = param; + } else { + state.session.recordVoteHistory = !state.session.recordVoteHistory; + } + }, toggleModal({ modals }, name) { if (name) { modals[name] = !modals[name]; diff --git a/src/store/modules/session.js b/src/store/modules/session.js index 5a79ec5..17aef66 100644 --- a/src/store/modules/session.js +++ b/src/store/modules/session.js @@ -71,6 +71,7 @@ const mutations = { * @param players */ addHistory(state, players) { + if (!state.recordVoteHistory) return; if (!state.nomination || state.lockedVote <= players.length) return; const isBanishment = players[state.nomination[1]].role.team === "traveler"; state.voteHistory.push({ @@ -89,9 +90,6 @@ const mutations = { clearVoteHistory(state) { state.voteHistory = []; }, - toggleRecordVoteHistory(state) { - state.recordVoteHistory = !state.recordVoteHistory; - }, /** * Store a vote with and without syncing it to the live session. * This is necessary in order to prevent infinite voting loops. diff --git a/src/store/socket.js b/src/store/socket.js index e193a08..7c7e199 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -172,6 +172,10 @@ class LiveSession { if (!this._isSpectator) return; this._store.commit("toggleNight", params); break; + case "recordVoteHistory": + if (!this._isSpectator) return; + this._store.commit("toggleRecordVoteHistory", params); + break; case "votingSpeed": if (!this._isSpectator) return; this._store.commit("session/setVotingSpeed", params); @@ -268,6 +272,7 @@ class LiveSession { this._sendDirect(playerId, "gs", { gamestate: this._gamestate, isNight: grimoire.isNight, + recordVoteHistory: session.recordVoteHistory, nomination: session.nomination, votingSpeed: session.votingSpeed, lockedVote: session.lockedVote, @@ -289,6 +294,7 @@ class LiveSession { gamestate, isLightweight, isNight, + recordVoteHistory, nomination, votingSpeed, votes, @@ -340,6 +346,7 @@ class LiveSession { }); if (!isLightweight) { this._store.commit("toggleNight", !!isNight); + this._store.commit("toggleRecordVoteHistory", recordVoteHistory); this._store.commit("session/nomination", { nomination, votes, @@ -686,6 +693,17 @@ class LiveSession { this._send("isNight", this._store.state.grimoire.isNight); } + /** + * Send the recordVoteHistory state. ST only + */ + setRecordVoteHistory() { + if (this._isSpectator) return; + this._send( + "recordVoteHistory", + this._store.state.session.recordVoteHistory + ); + } + /** * Send the voting speed. ST only * @param votingSpeed voting speed in seconds, minimum 1 @@ -843,6 +861,9 @@ export default store => { case "toggleNight": session.setIsNight(); break; + case "toggleRecordVoteHistory": + session.setRecordVoteHistory(); + break; case "setEdition": session.sendEdition(); break;