Use a regular array for children for filtering (for now)

This commit is contained in:
SondreB 2023-02-07 00:23:23 +01:00
parent aff9368573
commit bfef6026bf
No known key found for this signature in database
GPG Key ID: D6CC44C75005FDBF
2 changed files with 20 additions and 5 deletions

View File

@ -95,6 +95,24 @@ export class UIService {
// return this.#eventsChanged.asObservable().pipe(map((data) => data.sort((a, b) => (a.created_at > b.created_at ? -1 : 1))));
}
children(parentId: string): NostrEventDocument[] {
// if (this.events.length > 4) {
// console.log('PARENT ID:', parentId);
// console.log(this.events);
// }
const filtered = this.events.filter((d) => d.parentEventId === parentId);
// if (filtered.length > 0) {
// console.log('filtered:', filtered);
// }
// console.log(parentId);
// console.log(this.events);
return filtered;
}
children$(parentId: string): Observable<NostrEventDocument[]> {
// const filtered = this.events$.pipe(filter((item, index) => sorted.findIndex((e) => e.pubkey == item.pubkey) === index));
return this.events$.pipe(
@ -219,6 +237,7 @@ export class UIService {
if (eTags.length > 0) {
event.rootEventId = eTags[0][1];
event.parentEventId = eTags[eTags.length - 1][1];
}
if (eTags.length < 2) {
@ -226,10 +245,6 @@ export class UIService {
event.replyEventId = eTags[1][1];
}
if (eTags.length > 0) {
event.parentEventId = eTags[eTags.length - 1][1];
}
return event;
}

View File

@ -1,4 +1,4 @@
<div class="thread-event" *ngFor="let event of ui.children$(event!.id!) | async" [ngClass]="{ 'no-lines': !optionsService.values.showLines, lines: optionsService.values.showLines }">
<div class="thread-event" *ngFor="let event of ui.children(event!.id!)" [ngClass]="{ 'no-lines': !optionsService.values.showLines, lines: optionsService.values.showLines }">
<!-- <span *ngIf="thread.getEvent(entry.id) as event"> -->
<span>
<div class="events-header">