Skip to content

Commit

Permalink
Add missing openPopover and closePopover functions to MenuBarModule
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldonadel committed Feb 2, 2024
1 parent 9743b64 commit 77361ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/menu-bar/electron/src/TrayGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Tray, Menu, screen, BrowserWindow, MenuItemConstructorOptions } from 'electron';
import { Tray, Menu, screen, BrowserWindow, MenuItemConstructorOptions, ipcMain } from 'electron';
import path from 'path';

export default class TrayGenerator {
Expand Down Expand Up @@ -35,9 +35,12 @@ export default class TrayGenerator {
this.mainWindow.setPosition(position.x, position.y, false);
this.mainWindow.show();
};
hideWindow = () => {
this.mainWindow.hide();
};
toggleWindow = () => {
if (this.mainWindow.isVisible()) {
this.mainWindow.hide();
this.hideWindow();
} else {
this.showWindow();
}
Expand All @@ -58,6 +61,9 @@ export default class TrayGenerator {
this.tray.setIgnoreDoubleClickEvents(true);
this.tray.on('click', this.toggleWindow);
this.tray.on('right-click', this.rightClickMenu);

ipcMain.handle('open-popover', this.showWindow);
ipcMain.handle('close-popover', this.hideWindow);
};
}
module.exports = TrayGenerator;
8 changes: 8 additions & 0 deletions apps/menu-bar/modules/menu-bar/electron/preload.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { ipcRenderer } from 'electron';

const MenuBarModule = {
name: 'MenuBar',
initialScreenSize: {
height: globalThis.screen?.height || 0,
width: globalThis.screen?.width || 0,
},
openPopover: () => {
ipcRenderer.invoke('open-popover');
},
closePopover: () => {
ipcRenderer.invoke('close-popover');
},
};

export default MenuBarModule;

0 comments on commit 77361ae

Please sign in to comment.