This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore notificationclick handler to activate the app. Fixes #16
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var remote = require('electron').remote; | ||
|
||
function listenNotification() { | ||
remote.getCurrentWindow().webContents.executeJavaScript( | ||
'new Promise((resolve, reject) => { if (SESSION) { console.log("SESSION avail"); SESSION.on("notificationClick", function () { resolve(); }); } });' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
).then(() => { | ||
remote.app.emit('activate'); | ||
listenNotification(); | ||
}); | ||
} | ||
|
||
function setupNotificationHandler() { | ||
document.addEventListener("DOMContentLoaded", function (event) { | ||
listenNotification(); | ||
}); | ||
} | ||
|
||
module.exports = setupNotificationHandler; |
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
It looks like there's a memory leak here: every time the user clicks on a notification, the existing event listener isn't removed, and a new one is added. Assuming that SESSION follows Node's EventEmitter API, this can be fixed by changing
.on(
to.once(
.