feat: automated outbox model
This commit is contained in:
@ -21,7 +21,6 @@ import {
|
||||
} from "@/Login";
|
||||
import { SnortPubKey } from "@/Const";
|
||||
import { SubscriptionEvent } from "@/Subscription";
|
||||
import useRelaysFeedFollows from "./RelaysFeedFollows";
|
||||
import { FollowLists, FollowsFeed, GiftsCache, Notifications, UserRelays } from "@/Cache";
|
||||
import { Nip28Chats, Nip4Chats } from "@/chat";
|
||||
import { useRefreshFeedCache } from "@/Hooks/useRefreshFeedcache";
|
||||
@ -226,11 +225,6 @@ export default function useLoginFeed() {
|
||||
|
||||
useEffect(() => {
|
||||
UserRelays.buffer(follows.item).catch(console.error);
|
||||
system.ProfileLoader.TrackMetadata(follows.item); // always track follows profiles
|
||||
system.ProfileLoader.TrackKeys(follows.item); // always track follows profiles
|
||||
}, [follows.item]);
|
||||
|
||||
const fRelays = useRelaysFeedFollows(follows.item);
|
||||
useEffect(() => {
|
||||
UserRelays.bulkSet(fRelays).catch(console.error);
|
||||
}, [fRelays]);
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
import { useMemo } from "react";
|
||||
import {
|
||||
HexKey,
|
||||
FullRelaySettings,
|
||||
TaggedNostrEvent,
|
||||
EventKind,
|
||||
NoteCollection,
|
||||
RequestBuilder,
|
||||
parseRelayTags,
|
||||
} from "@snort/system";
|
||||
import { useRequestBuilder } from "@snort/system-react";
|
||||
import debug from "debug";
|
||||
|
||||
import { UserRelays } from "@/Cache";
|
||||
|
||||
interface RelayList {
|
||||
pubkey: string;
|
||||
created_at: number;
|
||||
relays: FullRelaySettings[];
|
||||
}
|
||||
|
||||
export default function useRelaysFeedFollows(pubkeys: HexKey[]): Array<RelayList> {
|
||||
const sub = useMemo(() => {
|
||||
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]).since(since);
|
||||
return b;
|
||||
}, [pubkeys]);
|
||||
|
||||
function mapFromRelays(notes: Array<TaggedNostrEvent>): Array<RelayList> {
|
||||
return notes.map(ev => {
|
||||
return {
|
||||
pubkey: ev.pubkey,
|
||||
created_at: ev.created_at,
|
||||
relays: parseRelayTags(ev.tags),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const relays = useRequestBuilder(NoteCollection, sub);
|
||||
const notesRelays = relays.data?.filter(a => a.kind === EventKind.Relays) ?? [];
|
||||
return useMemo(() => {
|
||||
return mapFromRelays(notesRelays);
|
||||
}, [relays]);
|
||||
}
|
Reference in New Issue
Block a user