This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: focus window upon notification click
Upon clicking on a new email notification the application window will be showed fix #411
- Loading branch information
1 parent
eae1175
commit bc95060
Showing
11 changed files
with
231 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ module.exports = { | |
}, | ||
globals: { | ||
module: true, | ||
OUTPUT_DIR: true, | ||
}, | ||
overrides: [ | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ipcRenderer } from 'electron'; | ||
|
||
const originalNotification = window.Notification; | ||
|
||
window.Notification = function(title, opts) { | ||
const _notice = new originalNotification(title, opts); | ||
|
||
_notice.addEventListener('click', () => { | ||
ipcRenderer.sendToHost('notificationClick', opts); | ||
}); | ||
|
||
return _notice; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
import { ipcRenderer } from 'electron'; | ||
|
||
describe('/renderer/li/webview-preload', () => { | ||
const sandbox = sinon.createSandbox(); | ||
let originalNotification; | ||
|
||
beforeEach(() => { | ||
originalNotification = sinon.stub(); | ||
window.Notification = originalNotification; | ||
require('./webview-preload'); | ||
}); | ||
|
||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('should ipcRenderer.sendToHost upon click event', () => { | ||
const mockNoti = document.createElement('div'); | ||
originalNotification.returns(mockNoti); | ||
ipcRenderer.sendToHost = sinon.spy(); | ||
|
||
const noti = new Notification('read this'); | ||
|
||
const event = new MouseEvent('click', { bubbles: true, cancelable: false }); | ||
noti.dispatchEvent(event); | ||
|
||
expect(ipcRenderer.sendToHost).to.have.been.calledWith('notificationClick'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.