]> cat aescling's git repositories - mastodon.git/commitdiff
Minor refactoring and fixups
authorThibaut Girka <thib@sitedethib.com>
Sat, 19 Sep 2020 11:53:24 +0000 (13:53 +0200)
committerThibG <thib@sitedethib.com>
Sat, 19 Sep 2020 12:15:28 +0000 (14:15 +0200)
app/javascript/flavours/glitch/actions/notifications.js
app/javascript/flavours/glitch/features/notifications/components/notification.js
app/javascript/flavours/glitch/reducers/notifications.js

index b44469cf46f3a934c33c1c759556083dfb45c841..ccc427c2968e109fe9f3144c4b3c928530955984 100644 (file)
@@ -18,6 +18,7 @@ import compareId from 'flavours/glitch/util/compare_id';
 import { searchTextFromRawStatus } from 'flavours/glitch/actions/importer/normalizer';
 
 export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
+export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
 
 // tracking the notif cleaning request
 export const NOTIFICATIONS_DELETE_MARKED_REQUEST = 'NOTIFICATIONS_DELETE_MARKED_REQUEST';
index 7b80c2228c97f9b56341b5f01c37c35ee3288910..bd415856c466a47aed9a5ea2b25a210c9841b2a6 100644 (file)
@@ -22,6 +22,7 @@ export default class Notification extends ImmutablePureComponent {
     cacheMediaWidth: PropTypes.func,
     cachedMediaWidth: PropTypes.number,
     onUnmount: PropTypes.func,
+    unread: PropTypes.bool,
   };
 
   render () {
index 7820f524f0e270d464038f685eb432b1129f7c97..67725b90251cb4137b4fa23220b3237bb99fdc1e 100644 (file)
@@ -138,16 +138,16 @@ const updateTop = (state, top) => {
     state = clearUnread(state);
   }
 
-  return state.set('top', top);
+  return state;
 };
 
 const deleteByStatus = (state, statusId) => {
-  const top = !(shouldCountUnreadNotifications(state));
-  if (!top) {
+  if (shouldCountUnreadNotifications(state)) {
     const lastReadId = state.get('lastReadId');
     const deletedUnread = state.get('items').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
     state = state.update('unread', unread => unread - deletedUnread.size);
   }
+
   const helper = list => list.filterNot(item => item !== null && item.get('status') === statusId);
   const deletedUnread = state.get('pendingItems').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
   state = state.update('unread', unread => unread - deletedUnread.size);