MCPcopy
hub / github.com/vercel/hyper / fetchNotifications

Function fetchNotifications

app/notifications.ts:8–38  ·  view source on GitHub ↗
(win: BrowserWindow)

Source from the content-addressed store, hash-verified

6const NEWS_URL = 'https://hyper-news.now.sh';
7
8export default function fetchNotifications(win: BrowserWindow) {
9 const {rpc} = win;
10 const retry = (err?: Error) => {
11 setTimeout(() => fetchNotifications(win), ms('30m'));
12 if (err) {
13 console.error('Notification messages fetch error', err.stack);
14 }
15 };
16 console.log('Checking for notification messages');
17 fetch(NEWS_URL, {
18 headers: {
19 'X-Hyper-Version': version,
20 'X-Hyper-Platform': process.platform
21 }
22 })
23 .then((res) => res.json())
24 .then((data) => {
25 const {message} = data || {};
26 if (typeof message !== 'object' && message !== '') {
27 throw new Error('Bad response');
28 }
29 if (message === '') {
30 console.log('No matching notification messages');
31 } else {
32 rpc.emit('add notification', message);
33 }
34
35 retry();
36 })
37 .catch(retry);
38}

Callers 2

retryFunction · 0.85
newWindowFunction · 0.85

Calls 4

fetchFunction · 0.85
retryFunction · 0.70
logMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected