clearing vote history as ST clears it for everyone

fixed role distribution bug
This commit is contained in:
Steffen 2020-12-22 11:32:00 +01:00
parent 7bf5f69fbc
commit 125d5a9510
4 changed files with 25 additions and 8 deletions

View File

@ -238,7 +238,7 @@ export default {
Math.round(Math.random() * 10000)
);
if (sessionId) {
this.$store.commit("session/clearHistory");
this.$store.commit("session/clearVoteHistory");
this.$store.commit("session/setSpectator", false);
this.$store.commit(
"session/setSessionId",
@ -281,7 +281,7 @@ export default {
"Enter the channel number / name of the session you want to join"
);
if (sessionId) {
this.$store.commit("session/clearHistory");
this.$store.commit("session/clearVoteHistory");
this.$store.commit("session/setSpectator", true);
this.$store.commit("toggleGrimoire", false);
this.$store.commit(

View File

@ -5,7 +5,7 @@
@close="toggleModal('voteHistory')"
>
<font-awesome-icon
@click="clearHistory"
@click="clearVoteHistory"
icon="trash-alt"
class="clear"
title="Clear history"
@ -52,7 +52,7 @@ export default {
},
methods: {
...mapMutations(["toggleModal"]),
...mapMutations("session", ["clearHistory"])
...mapMutations("session", ["clearVoteHistory"])
}
};
</script>

View File

@ -79,7 +79,7 @@ const mutations = {
.map(({ name }) => name)
});
},
clearHistory(state) {
clearVoteHistory(state) {
state.voteHistory = [];
},
/**

View File

@ -1,6 +1,7 @@
class LiveSession {
constructor(store) {
this._wss = "wss://live.clocktower.online:8080/";
//this._wss = "wss://baumgart.biz:8080/"; //todo: delete this
//this._wss = "ws://localhost:8081/";
this._socket = null;
this._isSpectator = true;
@ -153,6 +154,10 @@ class LiveSession {
if (!this._isSpectator) return;
this._store.commit("session/setVotingSpeed", params);
break;
case "clearVoteHistory":
if (!this._isSpectator) return;
this._store.commit("session/clearVoteHistory");
break;
case "isVoteInProgress":
if (!this._isSpectator) return;
this._store.commit("session/setVoteInProgress", params);
@ -566,10 +571,10 @@ class LiveSession {
{ index, property: "role", value: player.role.id }
];
}
if (Object.keys(message).length) {
this._send("direct", message);
}
});
if (Object.keys(message).length) {
this._send("direct", message);
}
}
/**
@ -604,6 +609,7 @@ class LiveSession {
if (this._isSpectator) return;
this._send("isNight", this._store.state.grimoire.isNight);
}
/**
* Send the voting speed. ST only
* @param votingSpeed voting speed in seconds, minimum 1
@ -615,6 +621,14 @@ class LiveSession {
}
}
/**
* Clear the vote history for everyone. ST only
*/
clearVoteHistory() {
if (this._isSpectator) return;
this._send("clearVoteHistory");
}
/**
* Send a vote. Player or ST
* @param index Seat of the player
@ -737,6 +751,9 @@ export default store => {
case "session/setVotingSpeed":
session.setVotingSpeed(payload);
break;
case "session/clearVoteHistory":
session.clearVoteHistory();
break;
case "toggleNight":
session.setIsNight();
break;