From 8a8f4b0e9430cd7259a364dfc8485b79d4093457 Mon Sep 17 00:00:00 2001 From: Nick Zuber Date: Mon, 12 Nov 2018 11:02:59 -0500 Subject: [PATCH] Fix notifications bug --- .gitignore | 3 --- src/pages/Notifications/index.js | 13 ++++++++----- src/providers/Storage.js | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 78c97d1..f491785 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,3 @@ npm-debug.log* yarn-debug.log* yarn-error.log* - -# private -/src/utils/mocks.js diff --git a/src/pages/Notifications/index.js b/src/pages/Notifications/index.js index 724a906..407094f 100644 --- a/src/pages/Notifications/index.js +++ b/src/pages/Notifications/index.js @@ -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 { diff --git a/src/providers/Storage.js b/src/providers/Storage.js index 7950c6e..f42bfe6 100644 --- a/src/providers/Storage.js +++ b/src/providers/Storage.js @@ -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__';