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() {
this.$store.commit("session/clearVoteHistory");
},
toggleRecordVoteHistory() {
this.$store.commit("session/toggleRecordVoteHistory");
},
...mapMutations([
"toggleGrimoire",
"toggleMenu",
"toggleImageOptIn",
"toggleMuted",
"toggleNight",
"toggleRecordVoteHistory",
"toggleNightOrder",
"setZoom",
"toggleModal"

View File

@ -147,13 +147,6 @@ 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];

View File

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

View File

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