From 147bb39954014d8b286f80bf30e56b6ea4046855 Mon Sep 17 00:00:00 2001 From: Vladimir Y Date: Wed, 16 May 2018 23:45:29 +0300 Subject: [PATCH] prevent context menu auto-closing on macOS * prevent "context-menu" event handlers duplication --- README.md | 2 +- src/electron/main/web-content-context-menu.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 42b8a3746..14f093237 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ is an unofficial [ProtonMail](https://protonmail.com/) desktop client. It's basi - Cross platform, Linux/OSX/Windows packages [provided](https://github.com/vladimiry/protonmail-desktop-app/releases). - Multi accounts support. - Automatic login into the app with remembered master password using [keytar](https://github.com/atom/node-keytar) module ("Keep me signed in" feature). -- Automatic login into ProtonMail accounts using either saved in the settings password or KeePass password manager.. Two Factor Authentication (2FA) [is supported](https://github.com/vladimiry/protonmail-desktop-app/issues/10). +- Automatic login into ProtonMail accounts using either saved in the settings password or KeePass password manager. Two Factor Authentication (2FA) [is supported](https://github.com/vladimiry/protonmail-desktop-app/issues/10). - Encrypted settings storage with switchable predefined key derivation and encryption presets. Argon2 is used as the default key derivation function. - Native notifications for individual accounts clicking on which focuses the app window and selects respective account in the accounts list. - System tray icon with a total number of unread messages shown on top of it. diff --git a/src/electron/main/web-content-context-menu.ts b/src/electron/main/web-content-context-menu.ts index 7322e3a00..8f4a9dc0f 100644 --- a/src/electron/main/web-content-context-menu.ts +++ b/src/electron/main/web-content-context-menu.ts @@ -1,5 +1,5 @@ import * as os from "os"; -import {app, clipboard, ContextMenuParams, Event, Menu, PopupOptions} from "electron"; +import {app, clipboard, ContextMenuParams, Event, Menu, PopupOptions, WebContents} from "electron"; import {Context} from "./model"; @@ -53,11 +53,11 @@ export function initWebContentContextMenu(ctx: Context) { selectionMenu.popup(popupOptions); } }; - - app.on("browser-window-created", (event, {webContents}) => { - webContents.on("context-menu", contextMenuEvenHandler); - }); - app.on("web-contents-created", (webContentsCreatedEvent, webContents) => { + const windowCreateHandler = (webContents: WebContents) => { + webContents.removeListener("context-menu", contextMenuEvenHandler); webContents.on("context-menu", contextMenuEvenHandler); - }); + }; + + app.on("browser-window-created", (event, {webContents}) => windowCreateHandler(webContents)); + app.on("web-contents-created", (webContentsCreatedEvent, webContents) => windowCreateHandler(webContents)); }