mirror of
https://github.com/hoornet/vega.git
synced 2026-05-06 12:19:11 -07:00
Fix empty Media feed: use 24h window instead of 2h
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
||||
import { fetchGlobalFeed } from "../../lib/nostr";
|
||||
import { fetchMediaFeed } from "../../lib/nostr";
|
||||
import { useMuteStore } from "../../stores/mute";
|
||||
import { parseContent, ContentSegment } from "../../lib/parsing";
|
||||
import { NoteCard } from "../feed/NoteCard";
|
||||
@@ -28,7 +28,7 @@ export function MediaFeed() {
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
fetchGlobalFeed(300)
|
||||
fetchMediaFeed(500)
|
||||
.then((notes) => {
|
||||
const mediaNotes = notes.filter((n) => hasMediaType(n.content, MEDIA_TYPES.all));
|
||||
setAllNotes(mediaNotes);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export { getNDK, getNDKUptimeMs, connectToRelays, ensureConnected, resetNDK, getStoredRelayUrls, normalizeRelayUrl, addRelay, removeRelay, fetchWithTimeout, withTimeout, FEED_TIMEOUT, THREAD_TIMEOUT, SINGLE_TIMEOUT } from "./core";
|
||||
export { fetchGlobalFeed, fetchFollowFeed, fetchUserNotes, fetchUserNotesNIP65, fetchNoteById, fetchReplies, publishNote, publishReply, publishRepost, publishQuote, fetchHashtagFeed, fetchThreadEvents, fetchAncestors } from "./notes";
|
||||
export { fetchGlobalFeed, fetchMediaFeed, fetchFollowFeed, fetchUserNotes, fetchUserNotesNIP65, fetchNoteById, fetchReplies, publishNote, publishReply, publishRepost, publishQuote, fetchHashtagFeed, fetchThreadEvents, fetchAncestors } from "./notes";
|
||||
export { publishProfile, publishContactList, fetchProfile, fetchFollowSuggestions, fetchMentions, fetchFollowers, fetchNewFollowers } from "./social";
|
||||
export { publishArticle, fetchArticle, fetchAuthorArticles, fetchArticleFeed, searchArticles, fetchByAddr } from "./articles";
|
||||
export { publishReaction, fetchReplyCount, fetchZapCount, fetchReactions, groupReactions, fetchBatchEngagement, fetchZapsReceived, fetchZapsSent } from "./engagement";
|
||||
|
||||
@@ -11,6 +11,15 @@ export async function fetchGlobalFeed(limit: number = 50): Promise<NDKEvent[]> {
|
||||
return Array.from(events).sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0));
|
||||
}
|
||||
|
||||
export async function fetchMediaFeed(limit: number = 500): Promise<NDKEvent[]> {
|
||||
const instance = getNDK();
|
||||
// Wider window (24h) since media notes are sparse among text notes
|
||||
const since = Math.floor(Date.now() / 1000) - 24 * 3600;
|
||||
const filter: NDKFilter = { kinds: [NDKKind.Text], limit, since };
|
||||
const events = await fetchWithTimeout(instance, filter, FEED_TIMEOUT);
|
||||
return Array.from(events).sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0));
|
||||
}
|
||||
|
||||
export async function fetchFollowFeed(pubkeys: string[], limit = 80): Promise<NDKEvent[]> {
|
||||
if (pubkeys.length === 0) return [];
|
||||
const instance = getNDK();
|
||||
|
||||
Reference in New Issue
Block a user