fixes by @ekmartin

This commit is contained in:
Guillermo Rauch 2016-10-04 13:27:27 -07:00
parent ffa6a89c5a
commit fec4954dc1
3 changed files with 22 additions and 28 deletions

View file

@ -1,4 +1,4 @@
import {INIT} from '../constants/index';
import {INIT} from '../constants';
import rpc from '../rpc';
export function init() {

View file

@ -33,16 +33,15 @@ export function fetchNotifications() {
console.log('Checking for notification messages');
fetch('https://hyper-news.now.sh')
.then(res => {
res.json()
.then(res => res.json())
.then(data => {
const {messages} = data || {};
if (!messages) {
throw new Error('Bad response');
}
const message = messages.filter(msg => {
const message = messages.find(msg => {
return matchVersion(msg.versions);
})[0];
});
if (message) {
dispatch(addNotificationMessage(
message.text,
@ -55,16 +54,11 @@ export function fetchNotifications() {
retry();
})
.catch(retry);
})
.catch(retry);
};
}
function matchVersion(versions) {
return versions.some(v => {
if (v === '*') {
return true;
}
return satisfies(version, v);
return v === '*' || satisfies(version, v);
});
}

View file

@ -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;