From 1cdeeb638c055064474805658c1c405761e08cf1 Mon Sep 17 00:00:00 2001 From: Gorbachev Egor <7gorbachevm@gmail.com> Date: Sat, 9 Dec 2023 12:41:50 +0700 Subject: [PATCH] Allow speaking card immediately --- src/store/deck-form-store.ts | 1 + src/store/deck-list-store.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/store/deck-form-store.ts b/src/store/deck-form-store.ts index 7f2c9229..354dc793 100644 --- a/src/store/deck-form-store.ts +++ b/src/store/deck-form-store.ts @@ -337,6 +337,7 @@ export class DeckFormStore { }) .then((response) => { this.form = createUpdateForm(response.id, response); + deckListStore.replaceDeck(response) }) .finally( action(() => { diff --git a/src/store/deck-list-store.ts b/src/store/deck-list-store.ts index 8b73fd6d..db176b7f 100644 --- a/src/store/deck-list-store.ts +++ b/src/store/deck-list-store.ts @@ -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 [];