nlc: toggle within session.js

This commit is contained in:
nicfreeman1209 2021-05-03 17:55:11 +01:00
parent 5edc476b08
commit e762e89485
4 changed files with 17 additions and 13 deletions

View File

@ -346,13 +346,15 @@ export default {
clearVoteHistory() { clearVoteHistory() {
this.$store.commit("session/clearVoteHistory"); this.$store.commit("session/clearVoteHistory");
}, },
toggleRecordVoteHistory() {
this.$store.commit("session/toggleRecordVoteHistory");
},
...mapMutations([ ...mapMutations([
"toggleGrimoire", "toggleGrimoire",
"toggleMenu", "toggleMenu",
"toggleImageOptIn", "toggleImageOptIn",
"toggleMuted", "toggleMuted",
"toggleNight", "toggleNight",
"toggleRecordVoteHistory",
"toggleNightOrder", "toggleNightOrder",
"setZoom", "setZoom",
"toggleModal" "toggleModal"

View File

@ -147,13 +147,6 @@ export default new Vuex.Store({
toggleNight: toggle("isNight"), toggleNight: toggle("isNight"),
toggleGrimoire: toggle("isPublic"), toggleGrimoire: toggle("isPublic"),
toggleImageOptIn: toggle("isImageOptIn"), 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) { toggleModal({ modals }, name) {
if (name) { if (name) {
modals[name] = !modals[name]; modals[name] = !modals[name];

View File

@ -38,6 +38,14 @@ const set = key => (state, val) => {
state[key] = val; state[key] = val;
}; };
const toggle = key => (state, val) => {
if (val === true || val === false) {
state[key] = val;
} else {
state[key] = !state[key];
}
};
const mutations = { const mutations = {
setPlayerId: set("playerId"), setPlayerId: set("playerId"),
setSpectator: set("isSpectator"), setSpectator: set("isSpectator"),
@ -46,6 +54,7 @@ const mutations = {
setPing: set("ping"), setPing: set("ping"),
setVotingSpeed: set("votingSpeed"), setVotingSpeed: set("votingSpeed"),
setVoteInProgress: set("isVoteInProgress"), setVoteInProgress: set("isVoteInProgress"),
toggleRecordVoteHistory: toggle("recordVoteHistory"),
claimSeat: set("claimedSeat"), claimSeat: set("claimedSeat"),
distributeRoles: set("isRolesDistributed"), distributeRoles: set("isRolesDistributed"),
setSessionId(state, sessionId) { setSessionId(state, sessionId) {

View File

@ -174,7 +174,7 @@ class LiveSession {
break; break;
case "recordVoteHistory": case "recordVoteHistory":
if (!this._isSpectator) return; if (!this._isSpectator) return;
this._store.commit("toggleRecordVoteHistory", params); this._store.commit("session/toggleRecordVoteHistory", params);
break; break;
case "votingSpeed": case "votingSpeed":
if (!this._isSpectator) return; if (!this._isSpectator) return;
@ -346,7 +346,7 @@ class LiveSession {
}); });
if (!isLightweight) { if (!isLightweight) {
this._store.commit("toggleNight", !!isNight); this._store.commit("toggleNight", !!isNight);
this._store.commit("toggleRecordVoteHistory", recordVoteHistory); this._store.commit("session/toggleRecordVoteHistory", recordVoteHistory);
this._store.commit("session/nomination", { this._store.commit("session/nomination", {
nomination, nomination,
votes, votes,
@ -858,12 +858,12 @@ export default store => {
case "session/clearVoteHistory": case "session/clearVoteHistory":
session.clearVoteHistory(); session.clearVoteHistory();
break; break;
case "session/toggleRecordVoteHistory":
session.setRecordVoteHistory();
break;
case "toggleNight": case "toggleNight":
session.setIsNight(); session.setIsNight();
break; break;
case "toggleRecordVoteHistory":
session.setRecordVoteHistory();
break;
case "setEdition": case "setEdition":
session.sendEdition(); session.sendEdition();
break; break;