mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Prewarm user's follow list, speed up discover plugins hook
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
|
||||
import { useNostr } from '@nostrify/react';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { useContacts } from '@/hooks/useContacts';
|
||||
|
||||
/**
|
||||
* NostrSync - Syncs user's Nostr data
|
||||
@@ -15,6 +16,9 @@ export function NostrSync() {
|
||||
const { user } = useCurrentUser();
|
||||
const { config, updateConfig } = useAppContext();
|
||||
|
||||
// Prewarm user's follow list
|
||||
useContacts(user?.pubkey);
|
||||
|
||||
useEffect(() => {
|
||||
if (!user) return;
|
||||
|
||||
|
||||
@@ -26,9 +26,7 @@ export function useDiscoverPlugins() {
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['discover-plugins', user?.pubkey, contacts],
|
||||
queryFn: async (c) => {
|
||||
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
|
||||
|
||||
queryFn: async () => {
|
||||
// Build authors list: current user + people they follow
|
||||
const authors: string[] = [];
|
||||
if (user?.pubkey) {
|
||||
@@ -54,7 +52,7 @@ export function useDiscoverPlugins() {
|
||||
limit: 100,
|
||||
},
|
||||
],
|
||||
{ signal }
|
||||
{ signal: AbortSignal.timeout(3000) }
|
||||
);
|
||||
|
||||
// Transform events into DiscoveredPlugin objects
|
||||
|
||||
Reference in new issue
Block a user