Skip to content

Commit

Permalink
fix: Show window on dock icon click (#279)
Browse files Browse the repository at this point in the history
* Show window on dock icon click

* Fix lint

* Update electron.ts
  • Loading branch information
RobbieTheWagner authored Apr 27, 2020
1 parent 9592f34 commit a8607fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ export class Menubar extends EventEmitter {
this.app.dock.hide();
}

this.app.on('activate', (_event, hasVisibleWindows) => {
if (!hasVisibleWindows) {
this.showWindow();
}
});

let trayImage =
this._options.icon || path.join(this._options.dir, 'IconTemplate.png');
if (typeof trayImage === 'string' && !fs.existsSync(trayImage)) {
Expand Down
5 changes: 4 additions & 1 deletion src/__mocks__/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ export const MOCK_APP_GETAPPPATH = 'mock.app.getAppPath';

export const app = {
getAppPath: jest.fn(() => MOCK_APP_GETAPPPATH),
isReady: (): Promise<void> => Promise.resolve()
isReady: (): Promise<void> => Promise.resolve(),
on: (): void => {
/* Do nothing */
}
};

export class BrowserWindow {
Expand Down

0 comments on commit a8607fa

Please sign in to comment.