Improve behavior of load more notifications btn

This commit is contained in:
Paul Frazee
2023-04-11 18:36:58 -07:00
parent 33f5ebf2de
commit 9be8867bc9
+8 -4
View File
@@ -314,7 +314,7 @@ export class NotificationsFeedModel {
*/ */
syncQueue = bundleAsync(async () => { syncQueue = bundleAsync(async () => {
this.rootStore.log.debug('NotificationsModel:syncQueue') this.rootStore.log.debug('NotificationsModel:syncQueue')
this.lock.acquireAsync() await this.lock.acquireAsync()
try { try {
const res = await this._fetchUntil( const res = await this._fetchUntil(
notif => notif =>
@@ -340,9 +340,12 @@ export class NotificationsFeedModel {
if (!this.queuedNotifications) { if (!this.queuedNotifications) {
return return
} }
this.lock.acquireAsync() this.isRefreshing = true
await this.lock.acquireAsync()
try { try {
this.mostRecentNotificationUri = this.queuedNotifications[0].uri runInAction(() => {
this.mostRecentNotificationUri = this.queuedNotifications?.[0].uri
})
const itemModels = await this._processNotifications( const itemModels = await this._processNotifications(
this.queuedNotifications, this.queuedNotifications,
) )
@@ -353,6 +356,7 @@ export class NotificationsFeedModel {
} catch (e) { } catch (e) {
this.rootStore.log.error('NotificationsModel:processQueue failed', {e}) this.rootStore.log.error('NotificationsModel:processQueue failed', {e})
} finally { } finally {
this.isRefreshing = false
this.lock.release() this.lock.release()
} }
}) })
@@ -364,7 +368,7 @@ export class NotificationsFeedModel {
if (!this.hasMore) { if (!this.hasMore) {
return return
} }
this.lock.acquireAsync() await this.lock.acquireAsync()
try { try {
this._xLoading() this._xLoading()
try { try {