diff --git a/resources/js/electron-plugin/dist/server/api/menuBar.js b/resources/js/electron-plugin/dist/server/api/menuBar.js index 9096fae0..0d6dc40d 100644 --- a/resources/js/electron-plugin/dist/server/api/menuBar.js +++ b/resources/js/electron-plugin/dist/server/api/menuBar.js @@ -36,8 +36,10 @@ router.post("/hide", (req, res) => { }); router.post("/create", (req, res) => { res.sendStatus(200); + let shouldSendCreatedEvent = true; if (state.activeMenuBar) { state.activeMenuBar.tray.destroy(); + shouldSendCreatedEvent = false; } const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextMenu, windowPosition, contextMenu, tooltip, resizable, event, } = req.body; if (onlyShowContextMenu) { @@ -88,6 +90,11 @@ router.post("/create", (req, res) => { } state.activeMenuBar.on("ready", () => { state.activeMenuBar.tray.setTitle(label); + if (shouldSendCreatedEvent) { + notifyLaravel("events", { + event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarCreated" + }); + } state.activeMenuBar.on("hide", () => { notifyLaravel("events", { event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarHidden" diff --git a/resources/js/electron-plugin/src/server/api/menuBar.ts b/resources/js/electron-plugin/src/server/api/menuBar.ts index c943e748..f0dc2070 100644 --- a/resources/js/electron-plugin/src/server/api/menuBar.ts +++ b/resources/js/electron-plugin/src/server/api/menuBar.ts @@ -55,8 +55,11 @@ router.post("/hide", (req, res) => { router.post("/create", (req, res) => { res.sendStatus(200); + let shouldSendCreatedEvent = true; + if (state.activeMenuBar) { state.activeMenuBar.tray.destroy(); + shouldSendCreatedEvent = false; } const { @@ -78,6 +81,7 @@ router.post("/create", (req, res) => { event, } = req.body; + if (onlyShowContextMenu) { const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png")); @@ -128,8 +132,15 @@ router.post("/create", (req, res) => { } state.activeMenuBar.on("ready", () => { + state.activeMenuBar.tray.setTitle(label); + if (shouldSendCreatedEvent) { + notifyLaravel("events", { + event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarCreated" + }); + } + state.activeMenuBar.on("hide", () => { notifyLaravel("events", { event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarHidden"