fix stale relays bug
Pulling data from kind 3 event instead of kind 65 since it's more widely supported. Also, turned off the cache to try to ensure that most recent relay data is displayed.
This commit is contained in:
parent
eddba62575
commit
6254149c2a
@ -7,29 +7,26 @@ export default function useRelaysFeed(pubkey: HexKey) {
|
|||||||
const sub = useMemo(() => {
|
const sub = useMemo(() => {
|
||||||
const x = new Subscriptions();
|
const x = new Subscriptions();
|
||||||
x.Id = `relays:${pubkey.slice(0, 12)}`;
|
x.Id = `relays:${pubkey.slice(0, 12)}`;
|
||||||
x.Kinds = new Set([EventKind.Relays]);
|
x.Kinds = new Set([EventKind.ContactList]);
|
||||||
x.Authors = new Set([pubkey]);
|
x.Authors = new Set([pubkey]);
|
||||||
x.Limit = 1;
|
x.Limit = 1;
|
||||||
return x;
|
return x;
|
||||||
}, [pubkey]);
|
}, [pubkey]);
|
||||||
|
|
||||||
const relays = useSubscription(sub, { leaveOpen: false, cache: true });
|
const relays = useSubscription(sub, { leaveOpen: false, cache: false });
|
||||||
const notes = relays.store.notes;
|
const eventContent = relays.store.notes[0]?.content;
|
||||||
const tags = notes.slice(-1)[0]?.tags || [];
|
|
||||||
return tags.reduce((rs, tag) => {
|
if (!eventContent) {
|
||||||
const [t, url, ...settings] = tag;
|
return [] as FullRelaySettings[];
|
||||||
if (t === "r") {
|
}
|
||||||
return [
|
|
||||||
...rs,
|
try {
|
||||||
{
|
return Object.entries(JSON.parse(eventContent)).map(([url, settings]) => ({
|
||||||
url,
|
url,
|
||||||
settings: {
|
settings,
|
||||||
read: settings.length === 0 || settings.includes("read"),
|
})) as FullRelaySettings[];
|
||||||
write: settings.length === 0 || settings.includes("write"),
|
} catch (error) {
|
||||||
},
|
console.error(error);
|
||||||
},
|
return [] as FullRelaySettings[];
|
||||||
];
|
}
|
||||||
}
|
|
||||||
return rs;
|
|
||||||
}, [] as FullRelaySettings[]);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user