Skip to content

Commit

Permalink
Handle if htmlBooks is missing (cached data) (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvire authored Nov 20, 2024
1 parent e7e62bf commit 6ec9f51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/data/catalogData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface CatalogData {
}[];
tags: {};
quizzes: {};
htmlBooks: {
htmlBooks?: {
id: string;
name: string;
}[];
Expand Down
7 changes: 5 additions & 2 deletions src/lib/data/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export class NavigationContext {
this.collection = docSet.split('_')[1];
this.catalog = await this.fetchCatalog(this.docSet);
this.books = this.catalog.documents.map((b) => b.bookCode);
this.allBookIds = [...this.books, ...this.catalog.htmlBooks.map((b) => b.id)];
this.allBookIds = [
...this.books,
...(this.catalog.htmlBooks ? this.catalog.htmlBooks.map((b) => b.id) : [])
];
newBook = true;
}
if (book !== this.book && this.allBookIds.includes(book)) {
Expand Down Expand Up @@ -128,7 +131,7 @@ export class NavigationContext {
return;
}

const htmlBook = this.catalog.htmlBooks.find((b) => b.id === this.book);
const htmlBook = this.catalog.htmlBooks?.find((b) => b.id === this.book);
if (htmlBook) {
this.title = htmlBook.name;
this.name = htmlBook.name;
Expand Down

0 comments on commit 6ec9f51

Please sign in to comment.