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)