From 9be8867bc96348fd5b0a8992d5c049d87c83372d Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 11 Apr 2023 18:36:58 -0700 Subject: [PATCH] Improve behavior of load more notifications btn --- src/state/models/feeds/notifications.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts index 455beaab22..15ead4b0da 100644 --- a/src/state/models/feeds/notifications.ts +++ b/src/state/models/feeds/notifications.ts @@ -314,7 +314,7 @@ export class NotificationsFeedModel { */ syncQueue = bundleAsync(async () => { this.rootStore.log.debug('NotificationsModel:syncQueue') - this.lock.acquireAsync() + await this.lock.acquireAsync() try { const res = await this._fetchUntil( notif => @@ -340,9 +340,12 @@ export class NotificationsFeedModel { if (!this.queuedNotifications) { return } - this.lock.acquireAsync() + this.isRefreshing = true + await this.lock.acquireAsync() try { - this.mostRecentNotificationUri = this.queuedNotifications[0].uri + runInAction(() => { + this.mostRecentNotificationUri = this.queuedNotifications?.[0].uri + }) const itemModels = await this._processNotifications( this.queuedNotifications, ) @@ -353,6 +356,7 @@ export class NotificationsFeedModel { } catch (e) { this.rootStore.log.error('NotificationsModel:processQueue failed', {e}) } finally { + this.isRefreshing = false this.lock.release() } }) @@ -364,7 +368,7 @@ export class NotificationsFeedModel { if (!this.hasMore) { return } - this.lock.acquireAsync() + await this.lock.acquireAsync() try { this._xLoading() try {