mirror of
https://github.com/kennethnym/aris.git
synced 2026-03-20 09:01:19 +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:
@@ -111,10 +111,10 @@ export class WeatherSource implements FeedSource<WeatherFeedItem> {
|
||||
this.units = options.units ?? Units.metric
|
||||
}
|
||||
|
||||
async fetchContext(context: Context): Promise<Partial<Context>> {
|
||||
async fetchContext(context: Context): Promise<Partial<Context> | null> {
|
||||
const location = contextValue(context, LocationKey)
|
||||
if (!location) {
|
||||
return {}
|
||||
return null
|
||||
}
|
||||
|
||||
const response = await this.client.fetch({
|
||||
@@ -123,7 +123,7 @@ export class WeatherSource implements FeedSource<WeatherFeedItem> {
|
||||
})
|
||||
|
||||
if (!response.currentWeather) {
|
||||
return {}
|
||||
return null
|
||||
}
|
||||
|
||||
const weather: Weather = {
|
||||
|
||||
Reference in New Issue
Block a user