Fix unread notification count when polling (#16272)

* Fix unread notification count when polling

Fixes #16236

* Immediately fetch markers to avoid incorrect unread notification count
This commit is contained in:
Claire 2021-05-19 23:51:05 +02:00 committed by GitHub
parent 689974b1ed
commit 92f1d739b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -361,9 +361,9 @@ class UI extends React.PureComponent {
this.props.dispatch(closeOnboarding()); this.props.dispatch(closeOnboarding());
} }
this.props.dispatch(fetchMarkers());
this.props.dispatch(expandHomeTimeline()); this.props.dispatch(expandHomeTimeline());
this.props.dispatch(expandNotifications()); this.props.dispatch(expandNotifications());
setTimeout(() => this.props.dispatch(fetchMarkers()), 500);
setTimeout(() => this.props.dispatch(fetchFilters()), 500); setTimeout(() => this.props.dispatch(fetchFilters()), 500);
this.hotkeys.__mousetrap__.stopCallback = (e, element) => { this.hotkeys.__mousetrap__.stopCallback = (e, element) => {

View file

@ -106,7 +106,7 @@ const expandNormalizedNotifications = (state, notifications, next, isLoadingRece
} }
if (shouldCountUnreadNotifications(state)) { if (shouldCountUnreadNotifications(state)) {
mutable.update('unread', unread => unread + items.count(item => compareId(item.get('id'), lastReadId) > 0)); mutable.set('unread', mutable.get('pendingItems').count(item => item !== null) + mutable.get('items').count(item => item && compareId(item.get('id'), lastReadId) > 0));
} else { } else {
const mostRecent = items.find(item => item !== null); const mostRecent = items.find(item => item !== null);
if (mostRecent && compareId(lastReadId, mostRecent.get('id')) < 0) { if (mostRecent && compareId(lastReadId, mostRecent.get('id')) < 0) {