forked from Kieran/snort
chore: stop loading kind3 for relay info
This commit is contained in:
parent
0ebd2f167a
commit
f482c004b3
@ -3,7 +3,6 @@ import {
|
||||
HexKey,
|
||||
FullRelaySettings,
|
||||
TaggedNostrEvent,
|
||||
RelaySettings,
|
||||
EventKind,
|
||||
NoteCollection,
|
||||
RequestBuilder,
|
||||
@ -25,7 +24,7 @@ export default function useRelaysFeedFollows(pubkeys: HexKey[]): Array<RelayList
|
||||
const b = new RequestBuilder(`relays:follows`);
|
||||
const since = UserRelays.newest();
|
||||
debug("LoginFeed")("Loading relay lists since %s", new Date(since * 1000).toISOString());
|
||||
b.withFilter().authors(pubkeys).kinds([EventKind.Relays, EventKind.ContactList]).since(since);
|
||||
b.withFilter().authors(pubkeys).kinds([EventKind.Relays]).since(since);
|
||||
return b;
|
||||
}, [pubkeys]);
|
||||
|
||||
@ -49,40 +48,9 @@ export default function useRelaysFeedFollows(pubkeys: HexKey[]): Array<RelayList
|
||||
});
|
||||
}
|
||||
|
||||
// instead of discarding the follow list we should also use it for follow graph
|
||||
function mapFromContactList(notes: Array<TaggedNostrEvent>): Array<RelayList> {
|
||||
return notes.map(ev => {
|
||||
if (ev.content !== "" && ev.content !== "{}" && ev.content.startsWith("{") && ev.content.endsWith("}")) {
|
||||
try {
|
||||
const relays: Record<string, RelaySettings> = JSON.parse(ev.content);
|
||||
return {
|
||||
pubkey: ev.pubkey,
|
||||
created_at: ev.created_at,
|
||||
relays: Object.entries(relays)
|
||||
.map(([k, v]) => {
|
||||
return {
|
||||
url: sanitizeRelayUrl(k),
|
||||
settings: v,
|
||||
} as FullRelaySettings;
|
||||
})
|
||||
.filter(a => a.url !== undefined),
|
||||
};
|
||||
} catch {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
return {
|
||||
pubkey: ev.pubkey,
|
||||
created_at: 0,
|
||||
relays: [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const relays = useRequestBuilder(NoteCollection, sub);
|
||||
const notesRelays = relays.data?.filter(a => a.kind === EventKind.Relays) ?? [];
|
||||
const notesContactLists = relays.data?.filter(a => a.kind === EventKind.ContactList) ?? [];
|
||||
return useMemo(() => {
|
||||
return [...mapFromContactList(notesContactLists), ...mapFromRelays(notesRelays)];
|
||||
return mapFromRelays(notesRelays);
|
||||
}, [relays]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user