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

View File

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

View File

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

View File

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

View File

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