Add some relay display functions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/app",
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.13",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of svelte stores for use in building nostr client applications.",
|
||||
@@ -37,7 +37,7 @@
|
||||
"@welshman/net": "~0.0.25",
|
||||
"@welshman/signer": "~0.0.8",
|
||||
"@welshman/store": "~0.0.10",
|
||||
"@welshman/util": "~0.0.37",
|
||||
"@welshman/util": "~0.0.38",
|
||||
"fuse.js": "^7.0.0",
|
||||
"idb": "^8.0.0",
|
||||
"svelte": "^4.2.18",
|
||||
|
||||
@@ -2,7 +2,7 @@ import {writable, derived} from 'svelte/store'
|
||||
import {withGetter} from '@welshman/store'
|
||||
import {ctx, groupBy, indexBy, batch, now, uniq, batcher, postJson} from '@welshman/lib'
|
||||
import type {RelayProfile} from "@welshman/util"
|
||||
import {normalizeRelayUrl} from "@welshman/util"
|
||||
import {normalizeRelayUrl, displayRelayUrl, displayRelayProfile} from "@welshman/util"
|
||||
import {AuthStatus, asMessage, type Connection, type SocketMessage} from '@welshman/net'
|
||||
import {collection} from './collection'
|
||||
|
||||
@@ -88,6 +88,12 @@ export const {
|
||||
}),
|
||||
})
|
||||
|
||||
export const displayRelayByPubkey = (url: string) =>
|
||||
displayRelayProfile(relaysByUrl.get().get(url)?.profile, displayRelayUrl(url))
|
||||
|
||||
export const deriveRelayDisplay = (url: string) =>
|
||||
derived(deriveRelay(url), $relay => displayRelayProfile($relay?.profile, displayRelayUrl(url)))
|
||||
|
||||
// Utilities for syncing stats from connections to relays
|
||||
|
||||
type RelayStatsUpdate = [string, (stats: RelayStats) => void]
|
||||
|
||||
@@ -20,7 +20,7 @@ export class FeedLoader {
|
||||
this.compiler = new FeedCompiler(options)
|
||||
}
|
||||
|
||||
async getLoader([type, ...feed]: Feed, loadOpts: LoadOpts) {
|
||||
async getLoader([type, ...feed]: Feed, loadOpts: LoadOpts = {}) {
|
||||
if (this.compiler.canCompile([type, ...feed] as Feed)) {
|
||||
return this.getRequestsLoader(await this.compiler.compile([type, ...feed] as Feed), loadOpts)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/util",
|
||||
"version": "0.0.37",
|
||||
"version": "0.0.38",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of nostr-related utilities.",
|
||||
|
||||
@@ -72,6 +72,8 @@ export const normalizeRelayUrl = (url: string) => {
|
||||
|
||||
export const displayRelayUrl = (url: string) => last(url.split("://")).replace(/\/$/, "")
|
||||
|
||||
export const displayRelayProfile = (profile?: RelayProfile, fallback = "") => profile?.name || fallback
|
||||
|
||||
// In-memory relay implementation backed by Repository
|
||||
|
||||
export class Relay<E extends HashedEvent = TrustedEvent> extends Emitter {
|
||||
|
||||
Reference in New Issue
Block a user