error for custom feed when it is not valid or offlien

zio/stable
Ansh Nanda 2023-05-25 19:01:37 -07:00
parent 11262ffc83
commit bcedbbc8b3
1 changed files with 17 additions and 0 deletions

View File

@ -436,6 +436,9 @@ export class PostsFeedModel {
} else if (this.feedType === 'home') { } else if (this.feedType === 'home') {
return this.rootStore.agent.getTimeline(params as GetTimeline.QueryParams) return this.rootStore.agent.getTimeline(params as GetTimeline.QueryParams)
} else if (this.feedType === 'custom') { } else if (this.feedType === 'custom') {
this.checkIfCustomFeedIsOnlineAndValid(
params as GetCustomFeed.QueryParams,
)
return this.rootStore.agent.app.bsky.feed.getFeed( return this.rootStore.agent.app.bsky.feed.getFeed(
params as GetCustomFeed.QueryParams, params as GetCustomFeed.QueryParams,
) )
@ -445,4 +448,18 @@ export class PostsFeedModel {
) )
} }
} }
private async checkIfCustomFeedIsOnlineAndValid(
params: GetCustomFeed.QueryParams,
) {
const res = await this.rootStore.agent.app.bsky.feed.getFeedGenerator({
feed: params.feed,
})
if (!res.data.isOnline || !res.data.isValid) {
runInAction(() => {
this.error =
'This custom feed is not online or may be experiencing issues.'
})
}
}
} }