diff --git a/src/modules/nostr-feed/services/ScheduledEventService.ts b/src/modules/nostr-feed/services/ScheduledEventService.ts index 3b64c5a..6215e4b 100644 --- a/src/modules/nostr-feed/services/ScheduledEventService.ts +++ b/src/modules/nostr-feed/services/ScheduledEventService.ts @@ -194,19 +194,26 @@ export class ScheduledEventService extends BaseService { */ getTodaysEvents(userPubkey?: string): ScheduledEvent[] { const today = new Date().toISOString().split('T')[0] - const events = this.getEventsForDate(today) + let events = this.getEventsForDate(today) - // If no user pubkey provided, return all events - if (!userPubkey) return events + // Filter events based on participation (if user pubkey provided) + if (userPubkey) { + events = events.filter(event => { + // If event has no participants, it's community-wide (show to everyone) + if (!event.participants || event.participants.length === 0) return true - // Filter events based on participation - return events.filter(event => { - // If event has no participants, it's community-wide (show to everyone) - if (!event.participants || event.participants.length === 0) return true + // Otherwise, only show if user is a participant + return event.participants.some(p => p.pubkey === userPubkey) + }) + } - // Otherwise, only show if user is a participant - return event.participants.some(p => p.pubkey === userPubkey) + // Sort by start time (ascending order) + events.sort((a, b) => { + // ISO datetime strings can be compared lexicographically + return a.start.localeCompare(b.start) }) + + return events } /**