Skip to content

Commit 0ef239b

Browse files
authored
Fix menubar not ready (#150)
* fix: menubar not ready * fix: menubar not ready * fix: menubar not ready * feat: new menubar event * feat: new menubar event
1 parent a2bde07 commit 0ef239b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

resources/js/electron-plugin/dist/server/api/menuBar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ router.post("/hide", (req, res) => {
3636
});
3737
router.post("/create", (req, res) => {
3838
res.sendStatus(200);
39+
let shouldSendCreatedEvent = true;
3940
if (state.activeMenuBar) {
4041
state.activeMenuBar.tray.destroy();
42+
shouldSendCreatedEvent = false;
4143
}
4244
const { width, height, url, label, alwaysOnTop, vibrancy, backgroundColor, transparency, icon, showDockIcon, onlyShowContextMenu, windowPosition, contextMenu, tooltip, resizable, event, } = req.body;
4345
if (onlyShowContextMenu) {
@@ -88,6 +90,11 @@ router.post("/create", (req, res) => {
8890
}
8991
state.activeMenuBar.on("ready", () => {
9092
state.activeMenuBar.tray.setTitle(label);
93+
if (shouldSendCreatedEvent) {
94+
notifyLaravel("events", {
95+
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarCreated"
96+
});
97+
}
9198
state.activeMenuBar.on("hide", () => {
9299
notifyLaravel("events", {
93100
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarHidden"

resources/js/electron-plugin/src/server/api/menuBar.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ router.post("/hide", (req, res) => {
5555
router.post("/create", (req, res) => {
5656
res.sendStatus(200);
5757

58+
let shouldSendCreatedEvent = true;
59+
5860
if (state.activeMenuBar) {
5961
state.activeMenuBar.tray.destroy();
62+
shouldSendCreatedEvent = false;
6063
}
6164

6265
const {
@@ -78,6 +81,7 @@ router.post("/create", (req, res) => {
7881
event,
7982
} = req.body;
8083

84+
8185
if (onlyShowContextMenu) {
8286
const tray = new Tray(icon || state.icon.replace("icon.png", "IconTemplate.png"));
8387

@@ -128,8 +132,15 @@ router.post("/create", (req, res) => {
128132
}
129133

130134
state.activeMenuBar.on("ready", () => {
135+
131136
state.activeMenuBar.tray.setTitle(label);
132137

138+
if (shouldSendCreatedEvent) {
139+
notifyLaravel("events", {
140+
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarCreated"
141+
});
142+
}
143+
133144
state.activeMenuBar.on("hide", () => {
134145
notifyLaravel("events", {
135146
event: "\\Native\\Laravel\\Events\\MenuBar\\MenuBarHidden"

0 commit comments

Comments
 (0)