use saved pronouns and remove when leaving seat

This commit is contained in:
Alexander Fletcher 2022-05-30 20:13:56 +08:00
parent d0a117297c
commit 0e1cdbbb35
2 changed files with 11 additions and 3 deletions

View file

@ -333,6 +333,10 @@ export default {
claimSeat() { claimSeat() {
this.isMenuOpen = false; this.isMenuOpen = false;
this.$emit("trigger", ["claimSeat"]); this.$emit("trigger", ["claimSeat"]);
const savedPronouns = localStorage.getItem("pronouns");
if (savedPronouns) {
this.updatePlayer("pronouns", savedPronouns);
}
}, },
/** /**
* Allow the ST to override a locked vote. * Allow the ST to override a locked vote.

View file

@ -627,14 +627,18 @@ class LiveSession {
*/ */
_updateSeat([index, value]) { _updateSeat([index, value]) {
if (this._isSpectator) return; if (this._isSpectator) return;
const property = "id";
const players = this._store.state.players.players; const players = this._store.state.players.players;
// remove previous seat // remove previous seat
const oldIndex = players.findIndex(({ id }) => id === value); const oldIndex = players.findIndex(({ id }) => id === value);
if (oldIndex >= 0 && oldIndex !== index) { if (oldIndex >= 0 && oldIndex !== index) {
this._store.commit("players/update", { this._store.commit("players/update", {
player: players[oldIndex], player: players[oldIndex],
property, property: "id",
value: ""
});
this._store.commit("players/update", {
player: players[oldIndex],
property: "pronouns",
value: "" value: ""
}); });
} }
@ -642,7 +646,7 @@ class LiveSession {
if (index >= 0) { if (index >= 0) {
const player = players[index]; const player = players[index];
if (!player) return; if (!player) return;
this._store.commit("players/update", { player, property, value }); this._store.commit("players/update", { player, property: "id", value });
} }
// update player session list as if this was a ping // update player session list as if this was a ping
this._handlePing([true, value, 0]); this._handlePing([true, value, 0]);