Fix notifications bug

This commit is contained in:
Nick Zuber 2018-11-12 11:02:59 -05:00
parent 42688b0221
commit 8a8f4b0e94
3 changed files with 10 additions and 10 deletions

3
.gitignore vendored
View File

@ -19,6 +19,3 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# private
/src/utils/mocks.js

View File

@ -270,6 +270,7 @@ class NotificationsPage extends React.Component {
body: reasonByline,
icon: n.type === "Issue" ? issueIcon : prIcon,
badge: n.type === "Issue" ? issueIcon : prIcon,
requireInteraction: true,
});
notification.addEventListener('click', () => {
@ -278,7 +279,7 @@ class NotificationsPage extends React.Component {
})
// Manually close for legacy browser support.
setTimeout(notification.close.bind(notification), 4000);
setTimeout(notification.close.bind(notification), 10000);
}
getFilteredNotifications = () => {
@ -347,10 +348,12 @@ class NotificationsPage extends React.Component {
}
if (this.props.notificationsApi.newChanges) {
// we shouldn't do it like this. instead, we should have an additional state called
// "new changes" or something that the notifications api knows about.
// this will be whatever we get in the syncing/fetching response
this.sendWebNotification(this.props.notificationsApi.newChanges);
const filteredNewChanges = this.props.notificationsApi.newChanges.filter(n => (
scoredAndSortedNotifications.some(fn => fn.id === n.id)
));
if (filteredNewChanges.length > 0) {
this.sendWebNotification(filteredNewChanges);
}
}
return {

View File

@ -1,9 +1,9 @@
import React from 'react';
import moment from 'moment';
import {Status} from '../constants/status';
import {createMockNotifications} from '../utils/mocks';
// import {createMockNotifications} from '../utils/mocks';
const mockNotifications = createMockNotifications(100);
// const mockNotifications = createMockNotifications(100);
export const LOCAL_STORAGE_PREFIX = '__meteorite_noti_cache__';
export const LOCAL_STORAGE_USER_PREFIX = '__meteorite_user_cache__';