Minor refactoring and fixups

remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
Thibaut Girka 2020-09-19 13:53:24 +02:00 committed by ThibG
parent 85b9086e6b
commit 312c936d51
3 changed files with 5 additions and 3 deletions

View 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';

View File

@ -22,6 +22,7 @@ export default class Notification extends ImmutablePureComponent {
cacheMediaWidth: PropTypes.func,
cachedMediaWidth: PropTypes.number,
onUnmount: PropTypes.func,
unread: PropTypes.bool,
};
render () {

View 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);