From 8d66cf0023096a47d4ec78f35ce5b346b6f8b220 Mon Sep 17 00:00:00 2001 From: Pedro Pupo Sa da Costa Date: Tue, 6 Feb 2024 08:00:54 +0000 Subject: [PATCH] fix: prevent permanent error state --- .../question-bank-search-provider.ts | 14 ++++++++++---- .../src/annexes/annex-search/annex-search-item.tsx | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/providers/search/src/abstract-providers/question-bank-search-provider.ts b/libs/providers/search/src/abstract-providers/question-bank-search-provider.ts index 3e44328af..1da01c5f6 100644 --- a/libs/providers/search/src/abstract-providers/question-bank-search-provider.ts +++ b/libs/providers/search/src/abstract-providers/question-bank-search-provider.ts @@ -50,11 +50,17 @@ export abstract class QuestionBankSearchProvider< if (thisWork) return await thisWork; const newWork = (async () => { - const searchDocuments = await this.getSearchDocuments(bank); - const firstId = searchDocuments[0]?.id; - if (!firstId || this.searchIndex.has(firstId)) return; - await this.searchIndex.addAll(searchDocuments); + try { + const searchDocuments = await this.getSearchDocuments(bank); + const firstId = searchDocuments[0]?.id; + if (!firstId || this.searchIndex.has(firstId)) return; + await this.searchIndex.addAllAsync(searchDocuments); + } catch (e) { + console.error("Error indexing the question Bank", e); + this.initializeSearchIndex(bank); + } })(); + this.initializationWork.set(bank, newWork); await newWork; } diff --git a/libs/react/containers/src/annexes/annex-search/annex-search-item.tsx b/libs/react/containers/src/annexes/annex-search/annex-search-item.tsx index c42f237b0..624845a91 100644 --- a/libs/react/containers/src/annexes/annex-search/annex-search-item.tsx +++ b/libs/react/containers/src/annexes/annex-search/annex-search-item.tsx @@ -64,7 +64,7 @@ export const AnnexSearchItem: FunctionComponent<{ ))} - Learning OBjectives + Learning Objectives {result.learningObjectives.map(({ href, id }) => (