diff --git a/resources/js/electron-plugin/dist/server/api/notification.js b/resources/js/electron-plugin/dist/server/api/notification.js index d7c3e29b..20112864 100644 --- a/resources/js/electron-plugin/dist/server/api/notification.js +++ b/resources/js/electron-plugin/dist/server/api/notification.js @@ -3,9 +3,23 @@ import { Notification } from 'electron'; import { notifyLaravel } from "../utils"; const router = express.Router(); router.post('/', (req, res) => { - const { title, body, subtitle, silent, icon, hasReply, timeoutType, replyPlaceholder, sound, urgency, actions, closeButtonText, toastXml, customEvent: event } = req.body; + const { title, body, subtitle, silent, icon, hasReply, timeoutType, replyPlaceholder, sound, urgency, actions, closeButtonText, toastXml, event: customEvent } = req.body; const eventName = customEvent !== null && customEvent !== void 0 ? customEvent : '\\Native\\Laravel\\Events\\Notifications\\NotificationClicked'; - const notification = new Notification({ title, body, subtitle, silent, icon, hasReply, timeoutType, replyPlaceholder, sound, urgency, actions, closeButtonText, toastXml }); + const notification = new Notification({ + title, + body, + subtitle, + silent, + icon, + hasReply, + timeoutType, + replyPlaceholder, + sound, + urgency, + actions, + closeButtonText, + toastXml + }); notification.on("click", (event) => { notifyLaravel('events', { event: eventName, diff --git a/resources/js/electron-plugin/src/server/api/notification.ts b/resources/js/electron-plugin/src/server/api/notification.ts index e071d5cb..4673ec9d 100644 --- a/resources/js/electron-plugin/src/server/api/notification.ts +++ b/resources/js/electron-plugin/src/server/api/notification.ts @@ -1,24 +1,54 @@ -import express from 'express' -import { Notification } from 'electron' +import express from 'express'; +import { Notification } from 'electron'; import {notifyLaravel} from "../utils"; const router = express.Router(); router.post('/', (req, res) => { - const {title, body, subtitle, silent, icon, hasReply, timeoutType, replyPlaceholder, sound, urgency, actions, closeButtonText, toastXml, customEvent: event} = req.body + const { + title, + body, + subtitle, + silent, + icon, + hasReply, + timeoutType, + replyPlaceholder, + sound, + urgency, + actions, + closeButtonText, + toastXml, + event: customEvent + } = req.body; + const eventName = customEvent ?? '\\Native\\Laravel\\Events\\Notifications\\NotificationClicked'; - const notification = new Notification({title, body, subtitle, silent, icon, hasReply, timeoutType, replyPlaceholder, sound, urgency, actions, closeButtonText, toastXml}); + const notification = new Notification({ + title, + body, + subtitle, + silent, + icon, + hasReply, + timeoutType, + replyPlaceholder, + sound, + urgency, + actions, + closeButtonText, + toastXml + }); - notification.on("click", (event)=>{ + notification.on("click", (event) => { notifyLaravel('events', { event: eventName, payload: JSON.stringify(event) - }) - }) + }); + }); - notification.show() + notification.show(); - res.sendStatus(200) + res.sendStatus(200); }); export default router;