diff options
Diffstat (limited to 'src/state/models')
-rw-r--r-- | src/state/models/feeds/notifications.ts | 32 | ||||
-rw-r--r-- | src/state/models/feeds/posts.ts | 33 |
2 files changed, 48 insertions, 17 deletions
diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts index ea3538438..4daa3ca8d 100644 --- a/src/state/models/feeds/notifications.ts +++ b/src/state/models/feeds/notifications.ts @@ -191,6 +191,7 @@ export class NotificationsFeedModel { isRefreshing = false hasLoaded = false error = '' + loadMoreError = '' params: ListNotifications.QueryParams hasMore = true loadMoreCursor?: string @@ -305,10 +306,9 @@ export class NotificationsFeedModel { await this._appendAll(res) this._xIdle() } catch (e: any) { - this._xIdle() // don't bubble the error to the user - this.rootStore.log.error('NotificationsView: Failed to load more', { - params: this.params, - e, + this._xIdle(undefined, e) + runInAction(() => { + this.hasMore = false }) } } finally { @@ -317,6 +317,15 @@ export class NotificationsFeedModel { }) /** + * Attempt to load more again after a failure + */ + async retryLoadMore() { + this.loadMoreError = '' + this.hasMore = true + return this.loadMore() + } + + /** * Load more posts at the start of the notifications */ loadLatest = bundleAsync(async () => { @@ -443,13 +452,20 @@ export class NotificationsFeedModel { this.error = '' } - _xIdle(err?: any) { + _xIdle(error?: any, loadMoreError?: any) { this.isLoading = false this.isRefreshing = false this.hasLoaded = true - this.error = cleanError(err) - if (err) { - this.rootStore.log.error('Failed to fetch notifications', err) + this.error = cleanError(error) + this.loadMoreError = cleanError(loadMoreError) + if (error) { + this.rootStore.log.error('Failed to fetch notifications', error) + } + if (loadMoreError) { + this.rootStore.log.error( + 'Failed to load more notifications', + loadMoreError, + ) } } diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts index 9e593f313..0046f9781 100644 --- a/src/state/models/feeds/posts.ts +++ b/src/state/models/feeds/posts.ts @@ -213,6 +213,7 @@ export class PostsFeedModel { hasNewLatest = false hasLoaded = false error = '' + loadMoreError = '' params: GetTimeline.QueryParams | GetAuthorFeed.QueryParams hasMore = true loadMoreCursor: string | undefined @@ -382,12 +383,10 @@ export class PostsFeedModel { await this._appendAll(res) this._xIdle() } catch (e: any) { - this._xIdle() // don't bubble the error to the user - this.rootStore.log.error('FeedView: Failed to load more', { - params: this.params, - e, + this._xIdle(undefined, e) + runInAction(() => { + this.hasMore = false }) - this.hasMore = false } } finally { this.lock.release() @@ -395,6 +394,15 @@ export class PostsFeedModel { }) /** + * Attempt to load more again after a failure + */ + async retryLoadMore() { + this.loadMoreError = '' + this.hasMore = true + return this.loadMore() + } + + /** * Update content in-place */ update = bundleAsync(async () => { @@ -503,13 +511,20 @@ export class PostsFeedModel { this.error = '' } - _xIdle(err?: any) { + _xIdle(error?: any, loadMoreError?: any) { this.isLoading = false this.isRefreshing = false this.hasLoaded = true - this.error = cleanError(err) - if (err) { - this.rootStore.log.error('Posts feed request failed', err) + this.error = cleanError(error) + this.loadMoreError = cleanError(loadMoreError) + if (error) { + this.rootStore.log.error('Posts feed request failed', error) + } + if (loadMoreError) { + this.rootStore.log.error( + 'Posts feed load-more request failed', + loadMoreError, + ) } } |