diff --git a/src/app.css b/src/app.css index da20412..7a55d9d 100644 --- a/src/app.css +++ b/src/app.css @@ -506,11 +506,11 @@ /* Table of Contents highlighting */ .toc-highlight { - @apply bg-primary-100 dark:bg-primary-800 border-l-4 border-primary-600 dark:border-primary-400; + @apply bg-primary-200 dark:bg-primary-700 border-l-4 border-primary-600 dark:border-primary-400 font-medium; transition: all 0.2s ease-in-out; } .toc-highlight:hover { - @apply bg-primary-200 dark:bg-primary-700; + @apply bg-primary-300 dark:bg-primary-600; } } diff --git a/src/lib/data_structures/publication_tree.ts b/src/lib/data_structures/publication_tree.ts index 2fefad7..f87b1c3 100644 --- a/src/lib/data_structures/publication_tree.ts +++ b/src/lib/data_structures/publication_tree.ts @@ -246,8 +246,11 @@ export class PublicationTree implements AsyncIterable { async tryMoveTo(address?: string) { if (!address) { const startEvent = await this.#tree.#depthFirstRetrieve(); + if (!startEvent) { + return false; + } this.target = await this.#tree.#nodes - .get(startEvent!.tagAddress()) + .get(startEvent.tagAddress()) ?.value(); } else { this.target = await this.#tree.#nodes.get(address)?.value(); @@ -424,8 +427,7 @@ export class PublicationTree implements AsyncIterable { ): Promise> { if (!this.#cursor.target) { if (await this.#cursor.tryMoveTo(this.#bookmark)) { - const event = await this.getEvent(this.#cursor.target!.address); - return { done: false, value: event }; + return this.#yieldEventAtCursor(false); } } @@ -440,7 +442,10 @@ export class PublicationTree implements AsyncIterable { async #yieldEventAtCursor( done: boolean, ): Promise> { - const value = (await this.getEvent(this.#cursor.target!.address)) ?? null; + if (!this.#cursor.target) { + return { done, value: null }; + } + const value = (await this.getEvent(this.#cursor.target.address)) ?? null; return { done, value }; } @@ -471,7 +476,7 @@ export class PublicationTree implements AsyncIterable { continue; } - if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) { + if (this.#cursor.target && this.#cursor.target.status === PublicationTreeNodeStatus.Error) { return { done: false, value: null }; } @@ -479,7 +484,7 @@ export class PublicationTree implements AsyncIterable { } } while (this.#cursor.tryMoveToParent()); - if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) { + if (this.#cursor.target && this.#cursor.target.status === PublicationTreeNodeStatus.Error) { return { done: false, value: null }; } @@ -518,7 +523,7 @@ export class PublicationTree implements AsyncIterable { } } while (this.#cursor.tryMoveToParent()); - if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) { + if (this.#cursor.target && this.#cursor.target.status === PublicationTreeNodeStatus.Error) { return { done: false, value: null }; }