creating an action to store player pronoun in state and persist the data in local storage

This commit is contained in:
Dave 2021-01-27 19:41:28 +00:00
parent d74a9f2d76
commit e60def4226
3 changed files with 13 additions and 6 deletions

View File

@ -240,12 +240,12 @@ export default {
},
methods: {
changePronoun() {
if (this.session.isSpectator) return;
const pronoun =
prompt("Player preffered pronouns", this.player.pronoun) ||
this.player.pronoun;
this.updatePlayer("pronoun", pronoun, true);
this.$emit("trigger", ["updatePlayer", this.player, "pronoun", pronoun]);
const pronoun = prompt("Player preffered pronouns", this.player.pronoun);
this.$store.commit("players/setPronoun", {
player: this.player,
pronoun
});
this.isMenuOpen = false;
},
toggleStatus() {
if (this.grimoire.isPublic) {

View File

@ -107,6 +107,12 @@ const mutations = {
state.players[index][property] = value;
}
},
setPronoun(state, { player, pronoun }) {
const index = state.players.indexOf(player);
if (index >= 0) {
state.players[index].pronoun = pronoun;
}
},
add(state, name) {
state.players.push({
...NEWPLAYER,

View File

@ -122,6 +122,7 @@ module.exports = store => {
case "players/set":
case "players/swap":
case "players/move":
case "players/setPronoun":
if (state.players.players.length) {
localStorage.setItem(
"players",