mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
fixes by @ekmartin
This commit is contained in:
parent
ffa6a89c5a
commit
fec4954dc1
3 changed files with 22 additions and 28 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import {INIT} from '../constants/index';
|
||||
import {INIT} from '../constants';
|
||||
import rpc from '../rpc';
|
||||
|
||||
export function init() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue