From 8eed7920eb67e3ad192698df7cb35d878080e5bf Mon Sep 17 00:00:00 2001 From: Gorbachev Egor <7gorbachevm@gmail.com> Date: Sat, 9 Dec 2023 22:23:43 +0700 Subject: [PATCH] Avoid exception when deck isn't found --- functions/services/review-card.test.ts | 3 +-- src/store/deck-list-store.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/services/review-card.test.ts b/functions/services/review-card.test.ts index 7bbc3b7d..340a0d6b 100644 --- a/functions/services/review-card.test.ts +++ b/functions/services/review-card.test.ts @@ -73,13 +73,12 @@ test("difficult to remember card", () => { "wrong", "correct", "wrong", - "wrong", "correct", "correct", "correct", ]); - expect(intervals).toEqual([0.4, 0.94, 0.4, 0.4, 0.86, 1.94, 4.56]); + expect(intervals).toEqual([0.4, 0.94, 0.4, 0.92, 2.21, 5.53]); }); test("forgetting resets interval - non interrupted", () => { diff --git a/src/store/deck-list-store.ts b/src/store/deck-list-store.ts index db176b7f..a7d9cf68 100644 --- a/src/store/deck-list-store.ts +++ b/src/store/deck-list-store.ts @@ -218,8 +218,9 @@ export class DeckListStore { 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; + if (deckIndex !== -1) { + this.myInfo.value.myDecks[deckIndex] = deck; + } } get publicDecks() {