Skip to content

Commit

Permalink
feat: new menubar event
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Dec 29, 2024
1 parent dc3b564 commit b472583
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
11 changes: 9 additions & 2 deletions resources/js/electron-plugin/dist/server/api/menuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions resources/js/electron-plugin/src/server/api/menuBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"));

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

0 comments on commit b472583

Please sign in to comment.