From f5617d1b01e86adbca862e288a3088801cfb6320 Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 19 Sep 2023 13:04:19 +0100 Subject: [PATCH] Prettier --- packages/app/src/Element/Thread.tsx | 10 ++++--- packages/app/src/Feed/ThreadFeed.ts | 6 +--- packages/system/src/event-ext.ts | 2 +- packages/system/src/nostr-system.ts | 13 +++++---- packages/system/src/profile-cache.ts | 2 +- packages/system/src/query.ts | 4 +-- packages/system/src/request-builder.ts | 6 ++-- packages/system/src/request-trim.ts | 40 +++++++++++++------------- 8 files changed, 43 insertions(+), 40 deletions(-) diff --git a/packages/app/src/Element/Thread.tsx b/packages/app/src/Element/Thread.tsx index 4a250eae..29698173 100644 --- a/packages/app/src/Element/Thread.tsx +++ b/packages/app/src/Element/Thread.tsx @@ -154,8 +154,9 @@ const TierThree = ({ active, isLastSubthread, notes, related, chains, onNavigate return ( <>
+ className={`subthread-container ${hasMultipleNotes ? "subthread-multi" : ""} ${ + isLast ? "subthread-last" : "subthread-mid" + }`}> + className={`subthread-container ${lastReply ? "" : "subthread-multi"} ${ + lastReply ? "subthread-last" : "subthread-mid" + }`}> { sub.withFilter().kinds([EventKind.TextNote]).link(x).replyToLink(x); }); diff --git a/packages/system/src/event-ext.ts b/packages/system/src/event-ext.ts index 2795bf67..76feff64 100644 --- a/packages/system/src/event-ext.ts +++ b/packages/system/src/event-ext.ts @@ -111,7 +111,7 @@ export abstract class EventExt { pubKeys: [], } as Thread; const replyTags = ev.tags.filter(a => a[0] === "e" || a[0] === "a").map(a => EventExt.parseTag(a)); - if(replyTags.length > 0) { + if (replyTags.length > 0) { const marked = replyTags.some(a => a.marker); if (!marked) { ret.root = replyTags[0]; diff --git a/packages/system/src/nostr-system.ts b/packages/system/src/nostr-system.ts index 1439b7b8..b887c50b 100644 --- a/packages/system/src/nostr-system.ts +++ b/packages/system/src/nostr-system.ts @@ -296,11 +296,14 @@ export class NostrSystem extends ExternalStore implements System if (cacheResults.length > 0) { const resultIds = new Set(cacheResults.map(a => a.id)); f.ids = f.ids.filter(a => !resultIds.has(a)); - q.insertCompletedTrace({ - filters:[{...f, ids: [...resultIds]}], - strategy: RequestStrategy.ExplicitRelays, - relay: "" - }, cacheResults as Array); + q.insertCompletedTrace( + { + filters: [{ ...f, ids: [...resultIds] }], + strategy: RequestStrategy.ExplicitRelays, + relay: "", + }, + cacheResults as Array, + ); } } } diff --git a/packages/system/src/profile-cache.ts b/packages/system/src/profile-cache.ts index 16b06af9..6118a8ae 100644 --- a/packages/system/src/profile-cache.ts +++ b/packages/system/src/profile-cache.ts @@ -39,7 +39,7 @@ export class ProfileLoaderService { TrackMetadata(pk: HexKey | Array) { for (const p of Array.isArray(pk) ? pk : [pk]) { if (p.length === 64) { - this.#wantsMetadata.add(p) + this.#wantsMetadata.add(p); } } } diff --git a/packages/system/src/query.ts b/packages/system/src/query.ts index 076febec..a9f20b6f 100644 --- a/packages/system/src/query.ts +++ b/packages/system/src/query.ts @@ -198,14 +198,14 @@ export class Query implements QueryBase { } /** - * Insert a new trace as a placeholder + * Insert a new trace as a placeholder */ insertCompletedTrace(subq: BuiltRawReqFilter, data: Readonly>) { const qt = new QueryTrace( "", subq.filters, "", - () => { + () => { // nothing to close }, () => { diff --git a/packages/system/src/request-builder.ts b/packages/system/src/request-builder.ts index d54219c0..75feeb01 100644 --- a/packages/system/src/request-builder.ts +++ b/packages/system/src/request-builder.ts @@ -146,7 +146,9 @@ export class RequestBuilder { const filtersSquashed = [...relayMerged.values()].map(a => { return { - filters: system.QueryOptimizer.flatMerge(a.flatMap(b => b.filters.flatMap(c => system.QueryOptimizer.expandFilter(c)))), + filters: system.QueryOptimizer.flatMerge( + a.flatMap(b => b.filters.flatMap(c => system.QueryOptimizer.expandFilter(c))), + ), relay: a[0].relay, strategy: a[0].strategy, } as BuiltRawReqFilter; @@ -252,7 +254,7 @@ export class RequestFilterBuilder { if (link.type === NostrPrefix.Address) { this.tag("a", [`${link.kind}:${link.author}:${link.id}`]); link.relays?.forEach(v => this.relay(v)); - } else if(link.type === NostrPrefix.PublicKey || link.type === NostrPrefix.Profile) { + } else if (link.type === NostrPrefix.PublicKey || link.type === NostrPrefix.Profile) { this.tag("p", [link.id]); link.relays?.forEach(v => this.relay(v)); } else { diff --git a/packages/system/src/request-trim.ts b/packages/system/src/request-trim.ts index bc3da93d..b9a6a92d 100644 --- a/packages/system/src/request-trim.ts +++ b/packages/system/src/request-trim.ts @@ -4,23 +4,23 @@ import { ReqFilter } from "nostr"; * Remove empty filters, filters which would result in no results */ export function trimFilters(filters: Array) { - const fNew = []; - for(const f of filters) { - let arrays = 0; - for(const [k, v] of Object.entries(f)) { - if(Array.isArray(v)) { - arrays++; - if(v.length === 0) { - delete f[k]; - } - } - } - - if(arrays > 0 && Object.entries(f).some(v => Array.isArray(v))) { - fNew.push(f); - } else if(arrays === 0) { - fNew.push(f); - } - } - return fNew; -} \ No newline at end of file + const fNew = []; + for (const f of filters) { + let arrays = 0; + for (const [k, v] of Object.entries(f)) { + if (Array.isArray(v)) { + arrays++; + if (v.length === 0) { + delete f[k]; + } + } + } + + if (arrays > 0 && Object.entries(f).some(v => Array.isArray(v))) { + fNew.push(f); + } else if (arrays === 0) { + fNew.push(f); + } + } + return fNew; +}