Switch to new relays store

This commit is contained in:
Jon Staab
2025-10-24 09:38:57 -07:00
parent e163286dd4
commit 3dff1fcb4d
11 changed files with 53 additions and 45 deletions
+13 -3
View File
@@ -21,13 +21,14 @@ import {
DIRECT_MESSAGE_FILE,
verifiedSymbol,
} from "@welshman/util"
import type {Zapper, TrustedEvent} from "@welshman/util"
import type {Zapper, TrustedEvent, RelayProfile} from "@welshman/util"
import type {RepositoryUpdate, WrapItem} from "@welshman/net"
import type {Handle, Relay} from "@welshman/app"
import type {Handle, RelayStats} from "@welshman/app"
import {
plaintext,
tracker,
relays,
relayStats,
repository,
handles,
zappers,
@@ -157,13 +158,21 @@ const syncTracker = async () => {
}
const syncRelays = async () => {
const collection = new Collection<Relay>({table: "relays", getId: prop("url")})
const collection = new Collection<RelayProfile>({table: "relays", getId: prop("url")})
relays.set(await collection.get())
return throttled(3000, relays).subscribe(collection.set)
}
const syncRelayStats = async () => {
const collection = new Collection<RelayStats>({table: "relayStats", getId: prop("url")})
relayStats.set(await collection.get())
return throttled(3000, relayStats).subscribe(collection.set)
}
const syncHandles = async () => {
const collection = new Collection<Handle>({table: "handles", getId: prop("nip05")})
@@ -233,6 +242,7 @@ export const syncDataStores = async () => {
syncEvents(),
syncTracker(),
syncRelays(),
syncRelayStats(),
syncHandles(),
syncZappers(),
syncFreshness(),