Skip to content

Commit

Permalink
Fix menubar not ready (#150)
Browse files Browse the repository at this point in the history
* fix: menubar not ready

* fix: menubar not ready

* fix: menubar not ready

* feat: new menubar event

* feat: new menubar event
  • Loading branch information
SRWieZ authored Dec 29, 2024
1 parent a2bde07 commit 0ef239b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions resources/js/electron-plugin/dist/server/api/menuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions resources/js/electron-plugin/src/server/api/menuBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"));

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 0ef239b

Please sign in to comment.