Clean up projections

This commit is contained in:
Jon Staab
2026-06-18 11:40:39 -07:00
parent 772895e3ab
commit 393c95e107
6 changed files with 35 additions and 69 deletions
+3 -7
View File
@@ -1,9 +1,8 @@
import {derived} from "svelte/store"
import {fetchJson} from "@welshman/lib"
import type {Maybe} from "@welshman/lib"
import {displayRelayUrl, displayRelayProfile} from "@welshman/util"
import type {RelayProfile} from "@welshman/util"
import {LoadableMapPlugin, projection} from "./base.js"
import {LoadableMapPlugin} from "./base.js"
import type {Projection} from "./base.js"
/**
@@ -37,11 +36,8 @@ export class Relays extends LoadableMapPlugin<RelayProfile> {
}
}
display = (url: string): Projection<string> => {
const read = ($relay: Maybe<RelayProfile>) => displayRelayProfile($relay, displayRelayUrl(url))
return projection(derived(this.one(url), read), () => read(this.get(url)))
}
display = (url: string): Projection<string> =>
this.project(url, $relay => displayRelayProfile($relay, displayRelayUrl(url)))
hasNegentropy = async (url: string) => {
const relay = await this.load(url)