mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
Add AbortSignal's to things
This commit is contained in:
4 files changed
+13
-17
No files matched your search
@@ -17,17 +17,10 @@ export function useLoggedInAccounts() {
|
||||
const { data: authors = [] } = useQuery({
|
||||
queryKey: ['logins', logins.map((l) => l.id).join(';')],
|
||||
queryFn: async ({ signal }) => {
|
||||
let events: NostrEvent[] = [];
|
||||
|
||||
try {
|
||||
events = await nostr.query(
|
||||
[{ kinds: [0], authors: logins.map((l) => l.pubkey) }],
|
||||
{ signal: AbortSignal.any([signal, AbortSignal.timeout(500)]) },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error fetching accounts:', error);
|
||||
return [];
|
||||
}
|
||||
const events = await nostr.query(
|
||||
[{ kinds: [0], authors: logins.map((l) => l.pubkey) }],
|
||||
{ signal: AbortSignal.any([signal, AbortSignal.timeout(1500)]) },
|
||||
);
|
||||
|
||||
return logins.map(({ id, pubkey }): Account => {
|
||||
const event = events.find((e) => e.pubkey === pubkey);
|
||||
@@ -38,7 +31,8 @@ export function useLoggedInAccounts() {
|
||||
return { id, pubkey, metadata: {}, event };
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
retry: 3,
|
||||
});
|
||||
|
||||
// Current user is the first login
|
||||
|
||||
Reference in new issue
Block a user