Skip to content

Commit

Permalink
fix(ui): added card's state not being updated
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinfreund committed Dec 9, 2024
1 parent 38dcf99 commit c29e1ac
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/ui/UiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,24 @@ export class UiState {
addJoker (joker?: Joker) {
this.jokerContainer.insertAdjacentHTML('beforeend', '<joker-card></joker-card>')
const jokerEl = this.jokerContainer.lastElementChild
if (joker && jokerEl instanceof JokerCard) {
jokerEl.setJoker(joker)
if (jokerEl instanceof JokerCard) {
if (joker) {
jokerEl.setJoker(joker)
}

jokerEl.updateState()
}
}

addCard (card?: Card, isPlayed?: boolean) {
this.playingCardContainer.insertAdjacentHTML('beforeend', '<playing-card></playing-card>')
const el = this.playingCardContainer.lastElementChild
if (card && el instanceof PlayingCard) {
el.setCard(card, isPlayed)
if (el instanceof PlayingCard) {
if (card) {
el.setCard(card, isPlayed)
}

el.updateState()
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/ui/components/JokerCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ export class JokerCard extends DraggableCard {
if (this.#definition.hasIsActiveInput) this.isActiveCheckbox.checked = Boolean(isActive)
if (this.#definition.hasRankInput && rank) this.rankSelect.value = String(rank)
if (this.#definition.hasSuitInput && suit) this.suitSelect.value = String(suit)

this.updateState()
}

updateState () {
Expand Down
2 changes: 0 additions & 2 deletions src/ui/components/PlayingCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ export class PlayingCard extends DraggableCard {
this.editionSelect.value = edition
this.enhancementSelect.value = enhancement
this.sealSelect.value = seal

this.updateState()
}

updateState () {
Expand Down

0 comments on commit c29e1ac

Please sign in to comment.