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 [];