re-enabled custom role support

This commit is contained in:
Steffen 2021-02-03 22:12:38 +01:00
parent ec64584da5
commit d409186ff1
5 changed files with 20 additions and 20 deletions

View File

@ -83,6 +83,7 @@
</template> </template>
<template v-if="tab === 'session'"> <template v-if="tab === 'session'">
<!-- Session -->
<li class="headline" v-if="session.sessionId"> <li class="headline" v-if="session.sessionId">
{{ session.isSpectator ? "Playing" : "Hosting" }} {{ session.isSpectator ? "Playing" : "Hosting" }}
</li> </li>
@ -106,7 +107,10 @@
Send Characters Send Characters
<em><font-awesome-icon icon="theater-masks"/></em> <em><font-awesome-icon icon="theater-masks"/></em>
</li> </li>
<li v-if="session.isSpectator" @click="imageOptIn"> <li
v-if="session.isSpectator && !edition.isOfficial"
@click="imageOptIn"
>
Show Custom Images Show Custom Images
<em <em
><font-awesome-icon ><font-awesome-icon
@ -213,7 +217,7 @@ import { mapMutations, mapState } from "vuex";
export default { export default {
computed: { computed: {
...mapState(["grimoire", "session"]), ...mapState(["grimoire", "session", "edition"]),
...mapState("players", ["players"]) ...mapState("players", ["players"])
}, },
data() { data() {

View File

@ -4,8 +4,11 @@
class="edition" class="edition"
:class="['edition-' + edition.id]" :class="['edition-' + edition.id]"
:style="{ :style="{
backgroundImage: `url(${edition.logo || backgroundImage: `url(${
require('../assets/editions/' + edition.id + '.png')})` edition.logo && grimoire.isImageOptIn
? edition.logo
: require('../assets/editions/' + edition.id + '.png')
})`
}" }"
></li> ></li>
<li v-if="players.length - teams.traveler < 5"> <li v-if="players.length - teams.traveler < 5">

View File

@ -103,25 +103,23 @@ export default new Vuex.Store({
}, },
getters: { getters: {
/** /**
* Return all custom roles, with default values stripped. * Return all custom roles, with default values and non-essential data stripped.
* @param roles * @param roles
* @returns {[]} * @returns {[]}
*/ */
customRoles: ({ roles }) => { customRolesStripped: ({ roles }) => {
const customRoles = []; const customRoles = [];
const strippedProps = ["firstNightReminder", "otherNightReminder"]
roles.forEach(role => { roles.forEach(role => {
if (!role.isCustom) { if (!role.isCustom) {
customRoles.push({ id: role.id }); customRoles.push({ id: role.id });
} else { } else {
const strippedRole = {}; const strippedRole = {};
for (let prop in role) { for (let prop in role) {
const value = role[prop]; if (strippedProps.includes(prop)) {
if (
prop === "image" &&
value.toLocaleLowerCase().includes(imageBase)
) {
continue; continue;
} }
const value = role[prop];
if (prop !== "isCustom" && value !== customRole[prop]) { if (prop !== "isCustom" && value !== customRole[prop]) {
strippedRole[prop] = value; strippedRole[prop] = value;
} }

View File

@ -117,7 +117,7 @@ module.exports = store => {
} else { } else {
localStorage.setItem( localStorage.setItem(
"roles", "roles",
JSON.stringify(store.getters.customRoles) JSON.stringify(payload)
); );
} }
break; break;

View File

@ -354,12 +354,10 @@ class LiveSession {
const { edition } = this._store.state; const { edition } = this._store.state;
let roles; let roles;
if (!edition.isOfficial) { if (!edition.isOfficial) {
roles = Array.from(this._store.state.roles.keys()); roles = this._store.getters.customRolesStripped;
} }
this._sendDirect(playerId, "edition", { this._sendDirect(playerId, "edition", {
edition: edition.isOfficial edition: edition.isOfficial ? { id: edition.id } : edition,
? { id: edition.id }
: Object.assign({}, edition, { logo: "" }),
...(roles ? { roles } : {}) ...(roles ? { roles } : {})
}); });
} }
@ -374,10 +372,7 @@ class LiveSession {
if (!this._isSpectator) return; if (!this._isSpectator) return;
this._store.commit("setEdition", edition); this._store.commit("setEdition", edition);
if (roles) { if (roles) {
this._store.commit( this._store.commit("setCustomRoles", roles);
"setCustomRoles",
roles.map(id => ({ id }))
);
if (this._store.state.roles.size !== roles.length) { if (this._store.state.roles.size !== roles.length) {
const missing = []; const missing = [];
roles.forEach(id => { roles.forEach(id => {