File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 11const ms = require ( 'ms' ) ;
22const fetch = require ( 'node-fetch' ) ;
3- const { satisfies} = require ( 'semver' ) ;
43
5- const { version} = './package' ;
4+ const { version} = require ( './package' ) ;
65
76const NEWS_URL = 'https://hyper-news.now.sh' ;
8- const matchVersion = versions => (
9- versions . some ( v => v === '*' || satisfies ( version , v ) )
10- ) ;
117
128module . 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 ( ) ;
You can’t perform that action at this time.
0 commit comments