Minor refactoring and fixups
parent
42c6a85139
commit
4e59bb5f9f
|
@ -18,6 +18,7 @@ import compareId from 'flavours/glitch/util/compare_id';
|
||||||
import { searchTextFromRawStatus } from 'flavours/glitch/actions/importer/normalizer';
|
import { searchTextFromRawStatus } from 'flavours/glitch/actions/importer/normalizer';
|
||||||
|
|
||||||
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
|
||||||
|
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
|
||||||
|
|
||||||
// tracking the notif cleaning request
|
// tracking the notif cleaning request
|
||||||
export const NOTIFICATIONS_DELETE_MARKED_REQUEST = 'NOTIFICATIONS_DELETE_MARKED_REQUEST';
|
export const NOTIFICATIONS_DELETE_MARKED_REQUEST = 'NOTIFICATIONS_DELETE_MARKED_REQUEST';
|
||||||
|
|
|
@ -22,6 +22,7 @@ export default class Notification extends ImmutablePureComponent {
|
||||||
cacheMediaWidth: PropTypes.func,
|
cacheMediaWidth: PropTypes.func,
|
||||||
cachedMediaWidth: PropTypes.number,
|
cachedMediaWidth: PropTypes.number,
|
||||||
onUnmount: PropTypes.func,
|
onUnmount: PropTypes.func,
|
||||||
|
unread: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -138,16 +138,16 @@ const updateTop = (state, top) => {
|
||||||
state = clearUnread(state);
|
state = clearUnread(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.set('top', top);
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteByStatus = (state, statusId) => {
|
const deleteByStatus = (state, statusId) => {
|
||||||
const top = !(shouldCountUnreadNotifications(state));
|
if (shouldCountUnreadNotifications(state)) {
|
||||||
if (!top) {
|
|
||||||
const lastReadId = state.get('lastReadId');
|
const lastReadId = state.get('lastReadId');
|
||||||
const deletedUnread = state.get('items').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
|
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);
|
state = state.update('unread', unread => unread - deletedUnread.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const helper = list => list.filterNot(item => item !== null && item.get('status') === statusId);
|
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);
|
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);
|
state = state.update('unread', unread => unread - deletedUnread.size);
|
||||||
|
|
Loading…
Reference in New Issue