update: notify model & ipc

This commit is contained in:
srgooglo 2020-09-09 14:29:23 +02:00
parent fa57b87c4e
commit 38ce7697db
2 changed files with 7 additions and 11 deletions

View File

@ -18,7 +18,7 @@ const log = require('electron-log');
const packagejson = require('../package.json')
const is = require('electron-is')
const waitOn = require('wait-on');
const { title } = require('process');
const { getDoNotDisturb } = require('electron-notification-state')
let app_path = is.dev()? 'http://127.0.0.1:8000/' : `file://${path.join(__dirname, '..', 'renderer')}/index.html`;
let mainWindow;
@ -33,6 +33,7 @@ app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
const gotTheLock = app.requestSingleInstanceLock()
const notifySupport = Notification.isSupported()
const isNotDisturb = getDoNotDisturb()
// Prevent multiple instances
if (!gotTheLock) {
@ -41,7 +42,6 @@ if (!gotTheLock) {
function notify(params) {
if(!notifySupport || !params) return false
let options = {
title: "",
body: "",
@ -52,15 +52,10 @@ function notify(params) {
const keys = Object.keys(params)
const values = Object.values(params)
for (let index = 0; index < keys.length; index++) {
const element = array[index];
for (let i = 0; i < keys.length; i++) {
options[keys[i]] = values[i]
}
params.forEach(element => {
options[element] = element
})
new Notification(options).show()
}
@ -251,6 +246,6 @@ ipcMain.handle('appRestart', () => {
mainWindow.close();
});
ipcMain.handle('app_notify', () => {
notify({ title: "Bruh" })
ipcMain.handle('app_notify', (payload) => {
notify(payload)
})

View File

@ -46,6 +46,7 @@
"electron-config": "^2.0.0",
"electron-is": "^3.0.0",
"electron-log": "^4.2.4",
"electron-notification-state": "^1.0.4",
"electron-updater": "^4.3.4",
"enquire-js": "^0.2.1",
"feather-reactjs": "^2.0.13",