Filters scheduled events by participation

Ensures users only see scheduled events they are participating in or events that are open to everyone.

This change filters the list of today's scheduled events based on the current user's participation.
It only displays events where the user is listed as a participant or events that do not have any participants specified.
This commit is contained in:
padreug 2025-10-21 23:41:37 +02:00
parent 115f248ec5
commit 7d093bdccd
2 changed files with 31 additions and 5 deletions

View file

@ -1,6 +1,7 @@
import { computed } from 'vue'
import { injectService, SERVICE_TOKENS } from '@/core/di-container'
import type { ScheduledEventService, ScheduledEvent, EventCompletion } from '../services/ScheduledEventService'
import type { AuthService } from '@/modules/base/auth/auth-service'
import { useToast } from '@/core/composables/useToast'
/**
@ -8,8 +9,12 @@ import { useToast } from '@/core/composables/useToast'
*/
export function useScheduledEvents() {
const scheduledEventService = injectService<ScheduledEventService>(SERVICE_TOKENS.SCHEDULED_EVENT_SERVICE)
const authService = injectService<AuthService>(SERVICE_TOKENS.AUTH_SERVICE)
const toast = useToast()
// Get current user's pubkey
const currentUserPubkey = computed(() => authService?.user.value?.pubkey)
/**
* Get all scheduled events
*/
@ -27,11 +32,11 @@ export function useScheduledEvents() {
}
/**
* Get today's scheduled events
* Get today's scheduled events (filtered by current user participation)
*/
const getTodaysEvents = (): ScheduledEvent[] => {
if (!scheduledEventService) return []
return scheduledEventService.getTodaysEvents()
return scheduledEventService.getTodaysEvents(currentUserPubkey.value)
}
/**