From 46418ef6fdec103fca5981e5551af6551e60a519 Mon Sep 17 00:00:00 2001 From: padreug Date: Tue, 21 Oct 2025 22:47:34 +0200 Subject: [PATCH] Fetches profiles for event authors/completers Ensures profiles are fetched for authors and completers of scheduled events, improving user experience by displaying relevant user information. This is achieved by watching for scheduled events and completions, then fetching profiles for any new pubkeys encountered. --- .../nostr-feed/components/NostrFeed.vue | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/modules/nostr-feed/components/NostrFeed.vue b/src/modules/nostr-feed/components/NostrFeed.vue index 614eb90..e9592e5 100644 --- a/src/modules/nostr-feed/components/NostrFeed.vue +++ b/src/modules/nostr-feed/components/NostrFeed.vue @@ -99,7 +99,7 @@ const { getDisplayName, fetchProfiles } = useProfiles() const { getEventReactions, subscribeToReactions, toggleLike } = useReactions() // Use scheduled events service -const { getTodaysEvents, getCompletion, toggleComplete } = useScheduledEvents() +const { getTodaysEvents, getCompletion, toggleComplete, allCompletions } = useScheduledEvents() // Get today's scheduled events (reactive) const todaysScheduledEvents = computed(() => getTodaysEvents()) @@ -118,6 +118,40 @@ watch(notes, async (newNotes) => { } }, { immediate: true }) +// Watch for scheduled events and fetch profiles for event authors and completers +watch(todaysScheduledEvents, async (events) => { + if (events.length > 0) { + const pubkeys = new Set() + + // Add event authors + events.forEach(event => { + pubkeys.add(event.pubkey) + + // Add completer pubkey if event is completed + const eventAddress = `31922:${event.pubkey}:${event.dTag}` + const completion = getCompletion(eventAddress) + if (completion) { + pubkeys.add(completion.pubkey) + } + }) + + // Fetch all profiles + if (pubkeys.size > 0) { + await fetchProfiles([...pubkeys]) + } + } +}, { immediate: true }) + +// Watch for new completions and fetch profiles for completers +watch(allCompletions, async (completions) => { + if (completions.size > 0) { + const pubkeys = [...completions.values()].map(c => c.pubkey) + if (pubkeys.length > 0) { + await fetchProfiles(pubkeys) + } + } +}, { immediate: true }) + // Check if we have admin pubkeys configured const hasAdminPubkeys = computed(() => adminPubkeys.length > 0)