mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38: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';
|
import rpc from '../rpc';
|
||||||
|
|
||||||
export function init() {
|
export function init() {
|
||||||
|
|
|
||||||
|
|
@ -33,28 +33,25 @@ export function fetchNotifications() {
|
||||||
|
|
||||||
console.log('Checking for notification messages');
|
console.log('Checking for notification messages');
|
||||||
fetch('https://hyper-news.now.sh')
|
fetch('https://hyper-news.now.sh')
|
||||||
.then(res => {
|
.then(res => res.json())
|
||||||
res.json()
|
.then(data => {
|
||||||
.then(data => {
|
const {messages} = data || {};
|
||||||
const {messages} = data || {};
|
if (!messages) {
|
||||||
if (!messages) {
|
throw new Error('Bad response');
|
||||||
throw new Error('Bad response');
|
}
|
||||||
}
|
const message = messages.find(msg => {
|
||||||
const message = messages.filter(msg => {
|
return matchVersion(msg.versions);
|
||||||
return matchVersion(msg.versions);
|
});
|
||||||
})[0];
|
if (message) {
|
||||||
if (message) {
|
dispatch(addNotificationMessage(
|
||||||
dispatch(addNotificationMessage(
|
message.text,
|
||||||
message.text,
|
message.url,
|
||||||
message.url,
|
message.dismissable
|
||||||
message.dismissable
|
));
|
||||||
));
|
} else {
|
||||||
} else {
|
console.log('No matching notification messages');
|
||||||
console.log('No matching notification messages');
|
}
|
||||||
}
|
retry();
|
||||||
retry();
|
|
||||||
})
|
|
||||||
.catch(retry);
|
|
||||||
})
|
})
|
||||||
.catch(retry);
|
.catch(retry);
|
||||||
};
|
};
|
||||||
|
|
@ -62,9 +59,6 @@ export function fetchNotifications() {
|
||||||
|
|
||||||
function matchVersion(versions) {
|
function matchVersion(versions) {
|
||||||
return versions.some(v => {
|
return versions.some(v => {
|
||||||
if (v === '*') {
|
return v === '*' || satisfies(version, v);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return satisfies(version, v);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ const reducer = (state = initial, action) => {
|
||||||
case NOTIFICATION_MESSAGE:
|
case NOTIFICATION_MESSAGE:
|
||||||
state_ = state.merge({
|
state_ = state.merge({
|
||||||
messageText: action.text,
|
messageText: action.text,
|
||||||
messageURL: action.url || null,
|
messageURL: action.url,
|
||||||
messageDismissable: action.dismissable === true
|
messageDismissable: action.dismissable === true
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue