mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
update: notify model & ipc
This commit is contained in:
parent
fa57b87c4e
commit
38ce7697db
@ -18,7 +18,7 @@ const log = require('electron-log');
|
|||||||
const packagejson = require('../package.json')
|
const packagejson = require('../package.json')
|
||||||
const is = require('electron-is')
|
const is = require('electron-is')
|
||||||
const waitOn = require('wait-on');
|
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 app_path = is.dev()? 'http://127.0.0.1:8000/' : `file://${path.join(__dirname, '..', 'renderer')}/index.html`;
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
@ -33,6 +33,7 @@ app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
|
|||||||
|
|
||||||
const gotTheLock = app.requestSingleInstanceLock()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
const notifySupport = Notification.isSupported()
|
const notifySupport = Notification.isSupported()
|
||||||
|
const isNotDisturb = getDoNotDisturb()
|
||||||
|
|
||||||
// Prevent multiple instances
|
// Prevent multiple instances
|
||||||
if (!gotTheLock) {
|
if (!gotTheLock) {
|
||||||
@ -41,7 +42,6 @@ if (!gotTheLock) {
|
|||||||
|
|
||||||
function notify(params) {
|
function notify(params) {
|
||||||
if(!notifySupport || !params) return false
|
if(!notifySupport || !params) return false
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
title: "",
|
title: "",
|
||||||
body: "",
|
body: "",
|
||||||
@ -52,15 +52,10 @@ function notify(params) {
|
|||||||
const keys = Object.keys(params)
|
const keys = Object.keys(params)
|
||||||
const values = Object.values(params)
|
const values = Object.values(params)
|
||||||
|
|
||||||
for (let index = 0; index < keys.length; index++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
const element = array[index];
|
options[keys[i]] = values[i]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
params.forEach(element => {
|
|
||||||
options[element] = element
|
|
||||||
})
|
|
||||||
|
|
||||||
new Notification(options).show()
|
new Notification(options).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +246,6 @@ ipcMain.handle('appRestart', () => {
|
|||||||
mainWindow.close();
|
mainWindow.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('app_notify', () => {
|
ipcMain.handle('app_notify', (payload) => {
|
||||||
notify({ title: "Bruh" })
|
notify(payload)
|
||||||
})
|
})
|
@ -46,6 +46,7 @@
|
|||||||
"electron-config": "^2.0.0",
|
"electron-config": "^2.0.0",
|
||||||
"electron-is": "^3.0.0",
|
"electron-is": "^3.0.0",
|
||||||
"electron-log": "^4.2.4",
|
"electron-log": "^4.2.4",
|
||||||
|
"electron-notification-state": "^1.0.4",
|
||||||
"electron-updater": "^4.3.4",
|
"electron-updater": "^4.3.4",
|
||||||
"enquire-js": "^0.2.1",
|
"enquire-js": "^0.2.1",
|
||||||
"feather-reactjs": "^2.0.13",
|
"feather-reactjs": "^2.0.13",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user