Skip to content

Commit

Permalink
Fix + code style
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhamp committed Nov 4, 2024
1 parent 4b90097 commit 74ed980
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 11 deletions.
18 changes: 16 additions & 2 deletions resources/js/electron-plugin/dist/server/api/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
48 changes: 39 additions & 9 deletions resources/js/electron-plugin/src/server/api/notification.ts
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 74ed980

Please sign in to comment.