mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
* Bump `eslint-plugin-react`
* Add `eslint-config-xo-react`
* Add XO
* Remove eslint-related dependencies, add XO config and use XO as the linter
* Code style: Standard => XO ✨
* Use xo property to ignore files
* Fix remaining errors
42 lines
913 B
JavaScript
42 lines
913 B
JavaScript
const {resolve} = require('path');
|
|
|
|
const {app, BrowserWindow} = require('electron');
|
|
const isDev = require('electron-is-dev');
|
|
|
|
let win;
|
|
|
|
// the hack of all hacks
|
|
// electron doesn't have a built in notification thing,
|
|
// so we launch a window on which we can use the
|
|
// HTML5 `Notification` API :'(
|
|
|
|
let buffer = [];
|
|
|
|
app.on('ready', () => {
|
|
const win_ = new BrowserWindow({
|
|
show: false
|
|
});
|
|
const url = 'file://' + resolve(
|
|
isDev ? __dirname : app.getAppPath(),
|
|
'notify.html'
|
|
);
|
|
win_.loadURL(url);
|
|
win_.webContents.on('dom-ready', () => {
|
|
win = win_;
|
|
buffer.forEach(([title, body]) => {
|
|
notify(title, body);
|
|
});
|
|
buffer = null;
|
|
});
|
|
});
|
|
|
|
function notify(title, body) {
|
|
console.log(`[Notification] ${title}: ${body}`);
|
|
if (win) {
|
|
win.webContents.send('notification', {title, body});
|
|
} else {
|
|
buffer.push([title, body]);
|
|
}
|
|
}
|
|
|
|
module.exports = notify;
|