Skip to content

Commit

Permalink
Allow speaking card immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Dec 9, 2023
1 parent 9224af6 commit 1cdeeb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/store/deck-form-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export class DeckFormStore {
})
.then((response) => {
this.form = createUpdateForm(response.id, response);
deckListStore.replaceDeck(response)
})
.finally(
action(() => {
Expand Down
11 changes: 11 additions & 0 deletions src/store/deck-list-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ export class DeckListStore {
};
}

replaceDeck(deck: DeckWithCardsDbType) {
if (this.myInfo?.state !== "fulfilled") {
return;
}
const deckIndex = this.myInfo.value.myDecks.findIndex(
(myDeck) => myDeck.id === deck.id,
);
assert(deckIndex !== -1, "Deck not found in myDecks");
this.myInfo.value.myDecks[deckIndex] = deck;
}

get publicDecks() {
if (this.myInfo?.state !== "fulfilled") {
return [];
Expand Down

0 comments on commit 1cdeeb6

Please sign in to comment.