Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
fix(taskbar): open app window from taskbar
Browse files Browse the repository at this point in the history
Shows the application window when clicking on pinned to taskbar icon, when the application has
already been opened.

fix #228
  • Loading branch information
kontrollanten committed Mar 7, 2019
1 parent af15b38 commit b1948d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ if (!gotTheLock) {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
} else if (process.platform === 'win32') {
mainWindow.show();
}

mainWindow.focus();
Expand Down
16 changes: 15 additions & 1 deletion src/main/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app } = require('electron');
const { app, BrowserWindow } = require('electron');
const chai = require('chai');
const sinon = require('sinon');
const sinonChai = require('sinon-chai');
Expand Down Expand Up @@ -47,4 +47,18 @@ describe('App', () => {

expect(app.setAppUserModelId).to.have.been.calledWith(pkgJson.build.appId);
});

it('should call mainWindow.show when app is opened from taskbar in win32', () => {
app.requestSingleInstanceLock.returns(true);
require('./');

Object.defineProperty(process, 'platform', {
value: 'win32',
});
sandbox.spy(BrowserWindow.prototype, 'show');
sandbox.stub(BrowserWindow.prototype, 'isMinimized').returns(false);
app.emit('second-instance');

expect(BrowserWindow.prototype.show).to.have.been.called;
});
});

0 comments on commit b1948d8

Please sign in to comment.