Add retry-on-empty for followers, articles, and hashtag feeds

Same pattern as profile notes and notifications: if the first relay
fetch returns empty, wait 3s and retry once. Prevents false "No X
found" messages when relays are slow to connect.
This commit is contained in:
Jure
2026-03-29 20:06:00 +02:00
parent e86561379b
commit 2fed4e3e85
3 changed files with 35 additions and 5 deletions
+14 -1
View File
@@ -116,8 +116,21 @@ export function ProfileView() {
useEffect(() => {
if (profileTab !== "articles" || articles.length > 0) return;
let cancelled = false;
setArticlesLoading(true);
fetchAuthorArticles(pubkey).then(setArticles).catch(() => setArticles([])).finally(() => setArticlesLoading(false));
(async () => {
let result = await fetchAuthorArticles(pubkey).catch(() => [] as typeof articles);
if (result.length === 0 && !cancelled) {
await new Promise((r) => setTimeout(r, 3000));
if (cancelled) return;
result = await fetchAuthorArticles(pubkey).catch(() => [] as typeof articles);
}
if (!cancelled) {
setArticles(result);
setArticlesLoading(false);
}
})();
return () => { cancelled = true; };
}, [profileTab, pubkey]);
return (