mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
* Bumping electron to 3.0.10 * Updating node version in travis and appveyor * Fixing incorrect require of electron-fetch * Fix zoom to match previous versions Additionally I'm removing a call to disable pinch-zoom, it's disable by default since Electron 2 (https://electronjs.org/releases#2.0.0) * Bumping electron to 4.0.0-beta.8 * Bumping electron to 4.0.0-beta.9 * Work around for Copy accelerator not firing on electron v4 * Fixing header/titlebar in MacOS * Upgrading to electron 4.0.0 and node-pty 0.8.0 * Adding yarn.lock changes for electron 4.0.0 * Adding comments for editor:copy workaround. Scaling issue is only on Linux * Upgrading node-abi to support electron 4.0.0 * popup now takes an object as input
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
const ms = require('ms');
|
|
const fetch = require('electron-fetch').default;
|
|
|
|
const {version} = require('./package');
|
|
|
|
const NEWS_URL = 'https://hyper-news.now.sh';
|
|
|
|
module.exports = function fetchNotifications(win) {
|
|
const {rpc} = win;
|
|
const retry = err => {
|
|
setTimeout(() => fetchNotifications(win), ms('30m'));
|
|
if (err) {
|
|
//eslint-disable-next-line no-console
|
|
console.error('Notification messages fetch error', err.stack);
|
|
}
|
|
};
|
|
//eslint-disable-next-line no-console
|
|
console.log('Checking for notification messages');
|
|
fetch(NEWS_URL, {
|
|
headers: {
|
|
'X-Hyper-Version': version,
|
|
'X-Hyper-Platform': process.platform
|
|
}
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
const {message} = data || {};
|
|
if (typeof message !== 'object' && message !== '') {
|
|
throw new Error('Bad response');
|
|
}
|
|
if (message === '') {
|
|
//eslint-disable-next-line no-console
|
|
console.log('No matching notification messages');
|
|
} else {
|
|
rpc.emit('add notification', message);
|
|
}
|
|
|
|
retry();
|
|
})
|
|
.catch(retry);
|
|
};
|