chore: stop loading kind3 for relay info
This commit is contained in:
@ -3,7 +3,6 @@ import {
|
|||||||
HexKey,
|
HexKey,
|
||||||
FullRelaySettings,
|
FullRelaySettings,
|
||||||
TaggedNostrEvent,
|
TaggedNostrEvent,
|
||||||
RelaySettings,
|
|
||||||
EventKind,
|
EventKind,
|
||||||
NoteCollection,
|
NoteCollection,
|
||||||
RequestBuilder,
|
RequestBuilder,
|
||||||
@ -25,7 +24,7 @@ export default function useRelaysFeedFollows(pubkeys: HexKey[]): Array<RelayList
|
|||||||
const b = new RequestBuilder(`relays:follows`);
|
const b = new RequestBuilder(`relays:follows`);
|
||||||
const since = UserRelays.newest();
|
const since = UserRelays.newest();
|
||||||
debug("LoginFeed")("Loading relay lists since %s", new Date(since * 1000).toISOString());
|
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;
|
return b;
|
||||||
}, [pubkeys]);
|
}, [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 relays = useRequestBuilder(NoteCollection, sub);
|
||||||
const notesRelays = relays.data?.filter(a => a.kind === EventKind.Relays) ?? [];
|
const notesRelays = relays.data?.filter(a => a.kind === EventKind.Relays) ?? [];
|
||||||
const notesContactLists = relays.data?.filter(a => a.kind === EventKind.ContactList) ?? [];
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
return [...mapFromContactList(notesContactLists), ...mapFromRelays(notesRelays)];
|
return mapFromRelays(notesRelays);
|
||||||
}, [relays]);
|
}, [relays]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user