refactor: use nostr-social-graph
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
import { EventKind, HexKey, RequestBuilder, socialGraphInstance } from "@snort/system";
|
||||
import { EventKind, HexKey, RequestBuilder } from "@snort/system";
|
||||
import { useRequestBuilder } from "@snort/system-react";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import useWoT from "@/Hooks/useWoT";
|
||||
|
||||
export default function useFollowersFeed(pubkey?: HexKey) {
|
||||
const wot = useWoT();
|
||||
const sub = useMemo(() => {
|
||||
const b = new RequestBuilder(`followers`);
|
||||
if (pubkey) {
|
||||
@ -17,9 +20,7 @@ export default function useFollowersFeed(pubkey?: HexKey) {
|
||||
const contactLists = followersFeed?.filter(
|
||||
a => a.kind === EventKind.ContactList && a.tags.some(b => b[0] === "p" && b[1] === pubkey),
|
||||
);
|
||||
return [...new Set(contactLists?.map(a => a.pubkey))].sort((a, b) => {
|
||||
return socialGraphInstance.getFollowDistance(a) - socialGraphInstance.getFollowDistance(b);
|
||||
});
|
||||
return wot.sortEvents(contactLists);
|
||||
}, [followersFeed, pubkey]);
|
||||
|
||||
return followers;
|
||||
|
Reference in New Issue
Block a user