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.
This commit is contained in:
parent
033113829f
commit
46418ef6fd
1 changed files with 35 additions and 1 deletions
|
|
@ -99,7 +99,7 @@ const { getDisplayName, fetchProfiles } = useProfiles()
|
||||||
const { getEventReactions, subscribeToReactions, toggleLike } = useReactions()
|
const { getEventReactions, subscribeToReactions, toggleLike } = useReactions()
|
||||||
|
|
||||||
// Use scheduled events service
|
// Use scheduled events service
|
||||||
const { getTodaysEvents, getCompletion, toggleComplete } = useScheduledEvents()
|
const { getTodaysEvents, getCompletion, toggleComplete, allCompletions } = useScheduledEvents()
|
||||||
|
|
||||||
// Get today's scheduled events (reactive)
|
// Get today's scheduled events (reactive)
|
||||||
const todaysScheduledEvents = computed(() => getTodaysEvents())
|
const todaysScheduledEvents = computed(() => getTodaysEvents())
|
||||||
|
|
@ -118,6 +118,40 @@ watch(notes, async (newNotes) => {
|
||||||
}
|
}
|
||||||
}, { immediate: true })
|
}, { 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<string>()
|
||||||
|
|
||||||
|
// 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
|
// Check if we have admin pubkeys configured
|
||||||
const hasAdminPubkeys = computed(() => adminPubkeys.length > 0)
|
const hasAdminPubkeys = computed(() => adminPubkeys.length > 0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue