mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 00:51:20 +00:00
refactor: make fetchContext required on FeedSource
Sources that cannot provide context now return null instead of omitting the method. The engine checks the return value rather than method existence. Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
@@ -75,14 +75,14 @@ export class GoogleCalendarSource implements FeedSource<CalendarFeedItem> {
|
||||
this.lookaheadHours = options.lookaheadHours ?? DEFAULT_LOOKAHEAD_HOURS
|
||||
}
|
||||
|
||||
async fetchContext(context: Context): Promise<Partial<Context>> {
|
||||
async fetchContext(context: Context): Promise<Partial<Context> | null> {
|
||||
const events = await this.fetchAllEvents(context.time)
|
||||
|
||||
const now = context.time.getTime()
|
||||
const nextTimedEvent = events.find((e) => !e.isAllDay && e.startTime.getTime() > now)
|
||||
|
||||
if (!nextTimedEvent) {
|
||||
return {}
|
||||
return null
|
||||
}
|
||||
|
||||
const minutesUntilStart = (nextTimedEvent.startTime.getTime() - now) / 60_000
|
||||
|
||||
Reference in New Issue
Block a user