Browse Source

Ensure an alert is shown when publication sections are missing

master
buttercat1791 10 months ago
parent
commit
68d8a0085c
  1. 12
      src/lib/components/Publication.svelte
  2. 2
      src/lib/components/PublicationSection.svelte
  3. 16
      src/lib/data_structures/publication_tree.ts

12
src/lib/components/Publication.svelte

@ -29,7 +29,7 @@
// TODO: Test load handling. // TODO: Test load handling.
let leaves = $state<NDKEvent[]>([]); let leaves = $state<Array<NDKEvent | null>>([]);
let isLoading = $state<boolean>(false); let isLoading = $state<boolean>(false);
let isDone = $state<boolean>(false); let isDone = $state<boolean>(false);
let lastElementRef = $state<HTMLElement | null>(null); let lastElementRef = $state<HTMLElement | null>(null);
@ -48,16 +48,6 @@
break; break;
} }
if (value == null) {
isLoading = false;
break;
}
if (leaves.includes(value)) {
isLoading = false;
break;
}
leaves.push(value); leaves.push(value);
} }

2
src/lib/components/PublicationSection.svelte

@ -14,7 +14,7 @@
}: { }: {
address: string, address: string,
rootAddress: string, rootAddress: string,
leaves: NDKEvent[], leaves: Array<NDKEvent | null>,
ref: (ref: HTMLElement) => void, ref: (ref: HTMLElement) => void,
} = $props(); } = $props();

16
src/lib/data_structures/publication_tree.ts

@ -345,11 +345,19 @@ export class PublicationTree implements AsyncIterable<NDKEvent | null> {
continue; continue;
} }
if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) {
return { done: false, value: null };
}
const event = await this.getEvent(this.#cursor.target!.address); const event = await this.getEvent(this.#cursor.target!.address);
return { done: false, value: event }; return { done: false, value: event };
} }
} while (this.#cursor.tryMoveToParent()); } while (this.#cursor.tryMoveToParent());
if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) {
return { done: false, value: null };
}
// If we get to this point, we're at the root node (can't move up any more). // If we get to this point, we're at the root node (can't move up any more).
return { done: true, value: null }; return { done: true, value: null };
} }
@ -370,11 +378,19 @@ export class PublicationTree implements AsyncIterable<NDKEvent | null> {
continue; continue;
} }
if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) {
return { done: false, value: null };
}
const event = await this.getEvent(this.#cursor.target!.address); const event = await this.getEvent(this.#cursor.target!.address);
return { done: false, value: event }; return { done: false, value: event };
} }
} while (this.#cursor.tryMoveToParent()); } while (this.#cursor.tryMoveToParent());
if (this.#cursor.target!.status === PublicationTreeNodeStatus.Error) {
return { done: false, value: null };
}
return { done: true, value: null }; return { done: true, value: null };
} }

Loading…
Cancel
Save