Update to properly retreive stored spells

This commit is contained in:
William Moore 2023-07-01 22:00:11 -05:00
parent b3dbdd3280
commit 12596531a5

View File

@ -8,13 +8,6 @@ export class Place extends LitElement {
@property() getCurrentSpell: any = null;
constructor() {
super();
const storedSpells = JSON.parse(localStorage.getItem(this.location) ?? '[]');
this.spells = storedSpells;
}
static get properties() {
return {
location: {
@ -58,13 +51,16 @@ export class Place extends LitElement {
];
override render() {
const storedSpells = JSON.parse(localStorage.getItem(this.location) ?? '[]');
this.spells = storedSpells;
return html`
<div @click="${this.addSpell}">
<h3>${this.location}</h3>
<div class="place-spells">
${this.spells.sort(spellSort).map(spell => spell ? html`<dd-spell .spellRemover="${(name: string) => this.removeSpell(name)}" name="${spell.name}" cost=${spell.cost} color="${spell.color}" category="${spell.category}" ?cantripMagic="${spell.cantripMagic ?? false}" ?reserveMagic="${spell.reserveMagic ?? false}" description="${spell.description}"></dd-spell>` : '')}
<div @click="${this.addSpell}">
<h3>${this.location}</h3>
<div class="place-spells">
${this.spells.sort(spellSort).map(spell => spell ? html`<dd-spell .spellRemover="${(name: string) => this.removeSpell(name)}" name="${spell.name}" cost=${spell.cost} color="${spell.color}" category="${spell.category}" ?cantripMagic="${spell.cantripMagic ?? false}" ?reserveMagic="${spell.reserveMagic ?? false}" description="${spell.description}"></dd-spell>` : '')}
</div>
</div>
</div>
`;
}
}