refactor: address review comments

This commit is contained in:
Alejandro Gomez
2023-07-04 19:30:41 +02:00
parent 6661c7cb32
commit faf75eba69
2 changed files with 9 additions and 22 deletions

View File

@ -22,15 +22,7 @@ export function useProfile(link: NostrLink, leaveOpen = false) {
.kinds([LIVE_STREAM])
.authors([link.id]);
const b2 = new RequestBuilder(`profile-host:${link.id.slice(0, 12)}`);
b2.withOptions({
leaveOpen,
})
.withFilter()
.kinds([LIVE_STREAM])
.tag("p", [link.id]);
b.add(b2);
b.withFilter().kinds([LIVE_STREAM]).tag("p", [link.id]);
return b;
}, [link, leaveOpen]);
@ -70,8 +62,14 @@ export function useProfile(link: NostrLink, leaveOpen = false) {
.map((ev) => parseZap(ev, System.ProfileLoader.Cache))
.filter((z) => z && z.valid && z.receiver === link.id);
const sortedStreams = useMemo(() => {
const sorted = [...streams];
sorted.sort((a, b) => b.created_at - a.created_at);
return sorted;
}, [streams]);
return {
streams,
streams: sortedStreams,
zaps,
};
}