]> cat aescling's git repositories - mastodon.git/commitdiff
Fix issue checking for last unread notification when there are gaps
authorThibaut Girka <thib@sitedethib.com>
Thu, 8 Oct 2020 19:45:50 +0000 (21:45 +0200)
committerThibG <thib@sitedethib.com>
Thu, 8 Oct 2020 20:44:30 +0000 (22:44 +0200)
app/javascript/flavours/glitch/reducers/notifications.js

index 474ca30128e56f3df89f78309e5134a9a439a6f2..e136369ae3cbbf5e6704627d596ca7272f5c51f5 100644 (file)
@@ -206,7 +206,8 @@ const shouldCountUnreadNotifications = (state) => {
   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 && isOnTop && isMounted && lastItemReached);
 };