Skip to content

Commit

Permalink
fix opening in the browser links of the email message, closes #493
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Feb 22, 2022
1 parent cf94a76 commit e0827c9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "electron-mail",
"description": "Unofficial ProtonMail Desktop App",
"version": "4.13.4",
"version": "4.13.5",
"author": "Vladimir Yakovlev <[email protected]>",
"license": "GPL-3.0",
"homepage": "https://github.com/vladimiry/ElectronMail",
Expand Down
48 changes: 48 additions & 0 deletions patches/protonmail/link-handler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/packages/components/hooks/useLinkHandler.tsx b/packages/components/hooks/useLinkHandler.tsx
index e65208ec9..6178f5aaf 100644
--- a/packages/components/hooks/useLinkHandler.tsx
+++ b/packages/components/hooks/useLinkHandler.tsx
@@ -4,7 +4,7 @@ import punycode from 'punycode.js';

import { getSecondLevelDomain } from '@proton/shared/lib/helpers/url';
import { MailSettings } from '@proton/shared/lib/interfaces';
-import { isIE11, isEdge } from '@proton/shared/lib/helpers/browser';
+import { isIE11, isEdge, openNewTab } from '@proton/shared/lib/helpers/browser';
import isTruthy from '@proton/shared/lib/helpers/isTruthy';
import { PROTON_DOMAINS } from '@proton/shared/lib/constants';

@@ -162,6 +162,10 @@ export const useLinkHandler: UseLinkHandler = (
return;
}

+ event.preventDefault();
+ event.stopPropagation(); // Required for Safari
+ const encodedLink = await encoder(src);
+
if (
askForConfirmation &&
isExternal(src.raw) &&
@@ -169,20 +173,17 @@ export const useLinkHandler: UseLinkHandler = (
.filter(isTruthy) // currentDomain can be null
.some((domain) => isSubDomain(hostname, domain))
) {
- event.preventDefault();
- event.stopPropagation(); // Required for Safari
-
- const link = await encoder(src);
-
const modalId = createModal(
<LinkConfirmationModal
- link={link}
+ link={encodedLink}
onClose={() => setConfirmationModalID(undefined)}
isOutside={isOutside}
/>
);

setConfirmationModalID(modalId);
+ } else {
+ openNewTab(encodedLink);
}
});

4 changes: 4 additions & 0 deletions patches/protonmail/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"link-handler.patch",
"proton-mail.patch"
],
"proton-account": [
Expand All @@ -17,6 +18,7 @@
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"link-handler.patch",
"proton-account.patch"
],
"proton-calendar": [
Expand All @@ -26,6 +28,7 @@
"captcha-3.patch",
"pack-api-arg-2.patch",
"pack-webpack-config-1.patch",
"link-handler.patch",
"session-storage-2.patch"
],
"proton-drive": [
Expand All @@ -36,6 +39,7 @@
"pack-api-arg-3.patch",
"pack-webpack-config-2.patch",
"session-storage-2.patch",
"link-handler.patch",
"proton-drive.patch"
],
"proton-vpn-settings": [
Expand Down

0 comments on commit e0827c9

Please sign in to comment.