diff --git a/resources/js/electron-plugin/dist/server/api/menuBar.js b/resources/js/electron-plugin/dist/server/api/menuBar.js index e951f0b..072e270 100644 --- a/resources/js/electron-plugin/dist/server/api/menuBar.js +++ b/resources/js/electron-plugin/dist/server/api/menuBar.js @@ -35,10 +35,13 @@ router.post("/hide", (req, res) => { state.activeMenuBar.hideWindow(); }); router.post("/create", (req, res) => { + res.sendStatus(200); + const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextMenu, windowPosition, contextMenu, tooltip, resizable, event, } = req.body; + 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) { const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png")); tray.setContextMenu(buildMenu(contextMenu)); @@ -87,7 +90,11 @@ router.post("/create", (req, res) => { } state.activeMenuBar.on("ready", () => { state.activeMenuBar.tray.setTitle(label); - res.sendStatus(200); + 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 e2f651d..8334bde 100644 --- a/resources/js/electron-plugin/src/server/api/menuBar.ts +++ b/resources/js/electron-plugin/src/server/api/menuBar.ts @@ -53,10 +53,7 @@ router.post("/hide", (req, res) => { }); router.post("/create", (req, res) => { - - if (state.activeMenuBar) { - state.activeMenuBar.tray.destroy(); - } + res.sendStatus(200); const { width, @@ -77,6 +74,14 @@ router.post("/create", (req, res) => { event, } = req.body; + let shouldSendCreatedEvent = true; + + if (state.activeMenuBar) { + state.activeMenuBar.tray.destroy(); + shouldSendCreatedEvent = false; + } + + if (onlyShowContextMenu) { const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png")); @@ -130,7 +135,11 @@ router.post("/create", (req, res) => { state.activeMenuBar.tray.setTitle(label); - res.sendStatus(200); + if (shouldSendCreatedEvent) { + notifyLaravel("events", { + event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarCreated" + }); + } state.activeMenuBar.on("hide", () => { notifyLaravel("events", {