Skip to content

Commit 2b3c49b

Browse files
committed
Update hyper-news notification fetching
1 parent 4264493 commit 2b3c49b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

app/notifications.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
const ms = require('ms');
22
const fetch = require('node-fetch');
3-
const {satisfies} = require('semver');
43

5-
const {version} = './package';
4+
const {version} = require('./package');
65

76
const NEWS_URL = 'https://hyper-news.now.sh';
8-
const matchVersion = versions => (
9-
versions.some(v => v === '*' || satisfies(version, v))
10-
);
117

128
module.exports = function fetchNotifications(win) {
139
const {rpc} = win;
@@ -19,18 +15,22 @@ module.exports = function fetchNotifications(win) {
1915
};
2016

2117
console.log('Checking for notification messages');
22-
fetch(NEWS_URL)
18+
fetch(NEWS_URL, {
19+
headers: {
20+
'X-Hyper-Version': version,
21+
'X-Hyper-Platform': process.platform
22+
}
23+
})
2324
.then(res => res.json())
2425
.then(data => {
25-
const {messages} = data || {};
26-
if (!messages) {
26+
const {message} = data || {};
27+
if (typeof message !== 'object' && message !== '') {
2728
throw new Error('Bad response');
2829
}
29-
const message = messages.find(msg => matchVersion(msg.versions));
30-
if (message) {
31-
rpc.emit('add notification', message);
32-
} else {
30+
if (message === '') {
3331
console.log('No matching notification messages');
32+
} else {
33+
rpc.emit('add notification', message);
3434
}
3535

3636
retry();

0 commit comments

Comments
 (0)