Permalink
Browse files

Update `hyper-news` notification fetching

  • Loading branch information...
1 parent 4264493 commit 2b3c49b1ec587938ff47844ed928590dd255e105 @matheuss matheuss committed Dec 12, 2016
Showing with 12 additions and 12 deletions.
  1. +12 −12 app/notifications.js
View
@@ -1,13 +1,9 @@
const ms = require('ms');
const fetch = require('node-fetch');
-const {satisfies} = require('semver');
-const {version} = './package';
+const {version} = require('./package');
const NEWS_URL = 'https://hyper-news.now.sh';
-const matchVersion = versions => (
- versions.some(v => v === '*' || satisfies(version, v))
-);
module.exports = function fetchNotifications(win) {
const {rpc} = win;
@@ -19,18 +15,22 @@ module.exports = function fetchNotifications(win) {
};
console.log('Checking for notification messages');
- fetch(NEWS_URL)
+ fetch(NEWS_URL, {
+ headers: {
+ 'X-Hyper-Version': version,
+ 'X-Hyper-Platform': process.platform
+ }
+ })
.then(res => res.json())
.then(data => {
- const {messages} = data || {};
- if (!messages) {
+ const {message} = data || {};
+ if (typeof message !== 'object' && message !== '') {
throw new Error('Bad response');
}
- const message = messages.find(msg => matchVersion(msg.versions));
- if (message) {
- rpc.emit('add notification', message);
- } else {
+ if (message === '') {
console.log('No matching notification messages');
+ } else {
+ rpc.emit('add notification', message);
}
retry();

0 comments on commit 2b3c49b

Please sign in to comment.