about summary refs log tree commit diff
path: root/src/state/models/feeds/notifications.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/models/feeds/notifications.ts')
-rw-r--r--src/state/models/feeds/notifications.ts32
1 files changed, 24 insertions, 8 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,
+      )
     }
   }