mirror of https://github.com/bra1n/townsquare.git
creating an action to store player pronoun in state and persist the data in local storage
This commit is contained in:
parent
d74a9f2d76
commit
e60def4226
|
@ -240,12 +240,12 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changePronoun() {
|
changePronoun() {
|
||||||
if (this.session.isSpectator) return;
|
const pronoun = prompt("Player preffered pronouns", this.player.pronoun);
|
||||||
const pronoun =
|
this.$store.commit("players/setPronoun", {
|
||||||
prompt("Player preffered pronouns", this.player.pronoun) ||
|
player: this.player,
|
||||||
this.player.pronoun;
|
pronoun
|
||||||
this.updatePlayer("pronoun", pronoun, true);
|
});
|
||||||
this.$emit("trigger", ["updatePlayer", this.player, "pronoun", pronoun]);
|
this.isMenuOpen = false;
|
||||||
},
|
},
|
||||||
toggleStatus() {
|
toggleStatus() {
|
||||||
if (this.grimoire.isPublic) {
|
if (this.grimoire.isPublic) {
|
||||||
|
|
|
@ -107,6 +107,12 @@ const mutations = {
|
||||||
state.players[index][property] = value;
|
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) {
|
add(state, name) {
|
||||||
state.players.push({
|
state.players.push({
|
||||||
...NEWPLAYER,
|
...NEWPLAYER,
|
||||||
|
|
|
@ -122,6 +122,7 @@ module.exports = store => {
|
||||||
case "players/set":
|
case "players/set":
|
||||||
case "players/swap":
|
case "players/swap":
|
||||||
case "players/move":
|
case "players/move":
|
||||||
|
case "players/setPronoun":
|
||||||
if (state.players.players.length) {
|
if (state.players.players.length) {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"players",
|
"players",
|
||||||
|
|
Loading…
Reference in New Issue