diff --git a/lib/actions/index.js b/lib/actions/index.js index dfc52ac0..44dfe898 100644 --- a/lib/actions/index.js +++ b/lib/actions/index.js @@ -1,4 +1,4 @@ -import {INIT} from '../constants/index'; +import {INIT} from '../constants'; import rpc from '../rpc'; export function init() { diff --git a/lib/actions/notifications.js b/lib/actions/notifications.js index f0c0a6ef..2c6d6a72 100644 --- a/lib/actions/notifications.js +++ b/lib/actions/notifications.js @@ -33,28 +33,25 @@ export function fetchNotifications() { console.log('Checking for notification messages'); fetch('https://hyper-news.now.sh') - .then(res => { - res.json() - .then(data => { - const {messages} = data || {}; - if (!messages) { - throw new Error('Bad response'); - } - const message = messages.filter(msg => { - return matchVersion(msg.versions); - })[0]; - if (message) { - dispatch(addNotificationMessage( - message.text, - message.url, - message.dismissable - )); - } else { - console.log('No matching notification messages'); - } - retry(); - }) - .catch(retry); + .then(res => res.json()) + .then(data => { + const {messages} = data || {}; + if (!messages) { + throw new Error('Bad response'); + } + const message = messages.find(msg => { + return matchVersion(msg.versions); + }); + if (message) { + dispatch(addNotificationMessage( + message.text, + message.url, + message.dismissable + )); + } else { + console.log('No matching notification messages'); + } + retry(); }) .catch(retry); }; @@ -62,9 +59,6 @@ export function fetchNotifications() { function matchVersion(versions) { return versions.some(v => { - if (v === '*') { - return true; - } - return satisfies(version, v); + return v === '*' || satisfies(version, v); }); } diff --git a/lib/reducers/ui.js b/lib/reducers/ui.js index 4a108c85..410a4100 100644 --- a/lib/reducers/ui.js +++ b/lib/reducers/ui.js @@ -280,7 +280,7 @@ const reducer = (state = initial, action) => { case NOTIFICATION_MESSAGE: state_ = state.merge({ messageText: action.text, - messageURL: action.url || null, + messageURL: action.url, messageDismissable: action.dismissable === true }); break;