From bf23bf82bd332d7f0477df9c4fc5460e4b00f84b Mon Sep 17 00:00:00 2001 From: ThibG Date: Fri, 9 Oct 2020 17:12:52 +0200 Subject: [PATCH] Fix issue checking for last unread notification when there are gaps (#14960) --- app/javascript/mastodon/reducers/notifications.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/reducers/notifications.js b/app/javascript/mastodon/reducers/notifications.js index 98c91ebb25..216876134d 100644 --- a/app/javascript/mastodon/reducers/notifications.js +++ b/app/javascript/mastodon/reducers/notifications.js @@ -172,7 +172,8 @@ const shouldCountUnreadNotifications = (state, ignoreScroll = false) => { const isOnTop = state.get('top'); const isMounted = state.get('mounted') > 0; const lastReadId = state.get('lastReadId'); - const lastItemReached = !state.get('hasMore') || lastReadId === '0' || (!state.get('items').isEmpty() && compareId(state.get('items').last().get('id'), lastReadId) <= 0); + const lastItem = state.get('items').findLast(item => item !== null); + const lastItemReached = !state.get('hasMore') || lastReadId === '0' || (lastItem && compareId(lastItem.get('id'), lastReadId) <= 0); return !(isTabVisible && (ignoreScroll || isOnTop) && isMounted && lastItemReached); };