mirror of
https://github.com/hoornet/vega.git
synced 2026-05-11 06:39:10 -07:00
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:
@@ -13,11 +13,22 @@ export function HashtagFeed() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tag) return;
|
if (!tag) return;
|
||||||
|
let cancelled = false;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setNotes([]);
|
setNotes([]);
|
||||||
fetchHashtagFeed(tag)
|
(async () => {
|
||||||
.then(setNotes)
|
let result = await fetchHashtagFeed(tag).catch(() => [] as NDKEvent[]);
|
||||||
.finally(() => setLoading(false));
|
if (result.length === 0 && !cancelled) {
|
||||||
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
|
if (cancelled) return;
|
||||||
|
result = await fetchHashtagFeed(tag).catch(() => [] as NDKEvent[]);
|
||||||
|
}
|
||||||
|
if (!cancelled) {
|
||||||
|
setNotes(result);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => { cancelled = true; };
|
||||||
}, [tag]);
|
}, [tag]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -103,7 +103,13 @@ export function FollowsView() {
|
|||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
await ensureConnected();
|
await ensureConnected();
|
||||||
const result = await fetchFollowers(pubkey);
|
let result = await fetchFollowers(pubkey);
|
||||||
|
// Retry once if empty — relays may not be ready yet
|
||||||
|
if (result.length === 0) {
|
||||||
|
await new Promise((r) => setTimeout(r, 3000));
|
||||||
|
if (cancelled) return;
|
||||||
|
result = await fetchFollowers(pubkey);
|
||||||
|
}
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
setFollowers(result);
|
setFollowers(result);
|
||||||
setFollowersFetched(true);
|
setFollowersFetched(true);
|
||||||
|
|||||||
@@ -116,8 +116,21 @@ export function ProfileView() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (profileTab !== "articles" || articles.length > 0) return;
|
if (profileTab !== "articles" || articles.length > 0) return;
|
||||||
|
let cancelled = false;
|
||||||
setArticlesLoading(true);
|
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]);
|
}, [profileTab, pubkey]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user