Skip to content

Commit c4f835f

Browse files
committed
update @ProtonMail web clients
1 parent 98865ed commit c4f835f

File tree

5 files changed

+323
-11
lines changed

5 files changed

+323
-11
lines changed

patches/protonmail/common-5.patch

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
diff --git a/packages/components/containers/unleash/UnleashFlagProvider.tsx b/packages/components/containers/unleash/UnleashFlagProvider.tsx
2+
index 1531d1450b..a8a8d44677 100644
3+
--- a/packages/components/containers/unleash/UnleashFlagProvider.tsx
4+
+++ b/packages/components/containers/unleash/UnleashFlagProvider.tsx
5+
@@ -3,20 +3,21 @@ import { ReactNode } from 'react';
6+
import FlagProvider from '@unleash/proxy-client-react';
7+
import { IConfig } from 'unleash-proxy-client';
8+
9+
-import { Api } from '@proton/shared/lib/interfaces';
10+
+import { Api, ProtonConfig } from '@proton/shared/lib/interfaces';
11+
12+
import useApi from '../../hooks/useApi';
13+
+import { useConfig } from '@proton/components/hooks';
14+
15+
// Just something dummy to have a valid domain because the library does new URL
16+
const prefix = 'https://proton.me/';
17+
const url = new URL(prefix);
18+
19+
const customFetch =
20+
- (api: Api): typeof window.fetch =>
21+
+ (api: Api, {API_URL}: ProtonConfig): typeof window.fetch =>
22+
(url, config) => {
23+
if (typeof url === 'string') {
24+
return api({
25+
- url: `feature/v2/frontend${url.replace(prefix, '')}`,
26+
+ url: `${API_URL}/feature/v2/frontend${url.replace(prefix, '')}`,
27+
headers: config?.headers,
28+
silence: true,
29+
output: 'raw',
30+
@@ -30,6 +31,7 @@ interface Props {
31+
}
32+
33+
const UnleashFlagProvider = ({ children }: Props) => {
34+
+ const config = useConfig();
35+
const api = useApi();
36+
const unleashConfig: IConfig = {
37+
url,
38+
@@ -37,7 +39,7 @@ const UnleashFlagProvider = ({ children }: Props) => {
39+
appName: '-', // set by the server
40+
refreshInterval: 600, // refreshInterval in seconds, 10 mins
41+
disableMetrics: true,
42+
- fetch: customFetch(api),
43+
+ fetch: customFetch(api, config),
44+
};
45+
46+
return <FlagProvider config={unleashConfig}>{children}</FlagProvider>;
47+
148
diff --git a/packages/pack/scripts/validate.sh b/packages/pack/scripts/validate.sh
249
index 1a2ea64..bae388c 100755
350
--- a/packages/pack/scripts/validate.sh
@@ -106,6 +153,22 @@ index 36bd0c712..c2fb3681c 100644
106153
return;
107154
}
108155

156+
diff --git a/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx b/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
157+
index 24c56ef6fe..a6046b391c 100644
158+
--- a/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
159+
+++ b/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
160+
@@ -7,6 +7,10 @@ import { AutoDeleteUpsellModal, useModalState } from '@proton/components/compone
161+
import { PromotionBanner } from '@proton/components/containers';
162+
163+
const AutoDeleteFreeBanner = () => {
164+
+ if (___ELECTRON_MAIL_PROTON_SUPPRESS_UPSELL_ADS_PLACEHOLDER___) {
165+
+ return null;
166+
+ }
167+
+
168+
const [upsellModalProps, toggleUpsellModal, renderUpsellModal] = useModalState();
169+
170+
return (
171+
109172
diff --git a/applications/mail/src/app/hooks/useShowUpsellBanner.ts b/applications/mail/src/app/hooks/useShowUpsellBanner.ts
110173
index d203f913fa..178153c592 100644
111174
--- a/applications/mail/src/app/hooks/useShowUpsellBanner.ts

patches/protonmail/common-6.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ index 36bd0c712..c2fb3681c 100644
120120
return;
121121
}
122122

123+
diff --git a/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx b/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
124+
index 24c56ef6fe..a6046b391c 100644
125+
--- a/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
126+
+++ b/applications/mail/src/app/components/list/auto-delete/variations/AutoDeleteFreeBanner.tsx
127+
@@ -7,6 +7,10 @@ import { AutoDeleteUpsellModal, useModalState } from '@proton/components/compone
128+
import { PromotionBanner } from '@proton/components/containers';
129+
130+
const AutoDeleteFreeBanner = () => {
131+
+ if (___ELECTRON_MAIL_PROTON_SUPPRESS_UPSELL_ADS_PLACEHOLDER___) {
132+
+ return null;
133+
+ }
134+
+
135+
const [upsellModalProps, toggleUpsellModal, renderUpsellModal] = useModalState();
136+
137+
return (
138+
123139
diff --git a/applications/mail/src/app/hooks/useShowUpsellBanner.ts b/applications/mail/src/app/hooks/useShowUpsellBanner.ts
124140
index d203f913fa..178153c592 100644
125141
--- a/applications/mail/src/app/hooks/useShowUpsellBanner.ts

patches/protonmail/common-7.patch

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
diff --git a/packages/components/containers/unleash/UnleashFlagProvider.tsx b/packages/components/containers/unleash/UnleashFlagProvider.tsx
2+
index 1531d1450b..a8a8d44677 100644
3+
--- a/packages/components/containers/unleash/UnleashFlagProvider.tsx
4+
+++ b/packages/components/containers/unleash/UnleashFlagProvider.tsx
5+
@@ -3,20 +3,21 @@ import { ReactNode } from 'react';
6+
import FlagProvider from '@unleash/proxy-client-react';
7+
import { IConfig } from 'unleash-proxy-client';
8+
9+
-import { Api } from '@proton/shared/lib/interfaces';
10+
+import { Api, ProtonConfig } from '@proton/shared/lib/interfaces';
11+
12+
import useApi from '../../hooks/useApi';
13+
+import { useConfig } from '@proton/components/hooks';
14+
15+
// Just something dummy to have a valid domain because the library does new URL
16+
const prefix = 'https://proton.me/';
17+
const url = new URL(prefix);
18+
19+
const customFetch =
20+
- (api: Api): typeof window.fetch =>
21+
+ (api: Api, {API_URL}: ProtonConfig): typeof window.fetch =>
22+
(url, config) => {
23+
if (typeof url === 'string') {
24+
return api({
25+
- url: `feature/v2/frontend${url.replace(prefix, '')}`,
26+
+ url: `${API_URL}/feature/v2/frontend${url.replace(prefix, '')}`,
27+
headers: config?.headers,
28+
silence: true,
29+
output: 'raw',
30+
@@ -30,6 +31,7 @@ interface Props {
31+
}
32+
33+
const UnleashFlagProvider = ({ children }: Props) => {
34+
+ const config = useConfig();
35+
const api = useApi();
36+
const unleashConfig: IConfig = {
37+
url,
38+
@@ -37,7 +39,7 @@ const UnleashFlagProvider = ({ children }: Props) => {
39+
appName: '-', // set by the server
40+
refreshInterval: 600, // refreshInterval in seconds, 10 mins
41+
disableMetrics: true,
42+
- fetch: customFetch(api),
43+
+ fetch: customFetch(api, config),
44+
};
45+
46+
return <FlagProvider config={unleashConfig}>{children}</FlagProvider>;
47+
48+
diff --git a/packages/pack/scripts/validate.sh b/packages/pack/scripts/validate.sh
49+
index 1a2ea64..bae388c 100755
50+
--- a/packages/pack/scripts/validate.sh
51+
+++ b/packages/pack/scripts/validate.sh
52+
@@ -58,7 +58,7 @@ function main {
53+
fi;
54+
55+
if [ "$hasSourceMap" -eq 0 ]; then
56+
- hasError=true;
57+
+ #hasError=true;
58+
echo "[error] no SourceMaps found inside the directory: $OUTPUT_DIR";
59+
fi;
60+
61+
diff --git a/packages/pack/bin/protonPack.js b/packages/pack/bin/protonPack.js
62+
index 55715b89d..c87879ad4 100755
63+
--- a/packages/pack/bin/protonPack.js
64+
+++ b/packages/pack/bin/protonPack.js
65+
@@ -81,7 +81,7 @@ addGlobalOptions(program.command('build').description('create an optimized produ
66+
const outputPath = path.resolve('./dist');
67+
await commandWithLog(`rm -rf ${outputPath}`);
68+
await commandWithLog(
69+
- `${require.resolve('webpack-cli/bin/cli.js')} --progress --output-path=${outputPath} ${webpackArgs}`,
70+
+ `${require.resolve('webpack-cli/bin/cli.js')} --output-path=${outputPath} ${webpackArgs}`,
71+
{
72+
stdio: 'inherit',
73+
}
74+
75+
diff --git a/packages/shared/lib/helpers/browser.ts b/packages/shared/lib/helpers/browser.ts
76+
index 9aaa78a28..f3d24b47c 100644
77+
--- a/packages/shared/lib/helpers/browser.ts
78+
+++ b/packages/shared/lib/helpers/browser.ts
79+
@@ -1,6 +1,21 @@
80+
import UAParser from 'ua-parser-js';
81+
82+
const uaParser = new UAParser();
83+
+{
84+
+ const platform = String(navigator.platform);
85+
+ const userAgents = {
86+
+ linux: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
87+
+ windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
88+
+ macos: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
89+
+ } as const;
90+
+ uaParser.setUA(
91+
+ platform.startsWith("Linux")
92+
+ ? userAgents.linux
93+
+ : platform.startsWith("Win")
94+
+ ? userAgents.windows
95+
+ : userAgents.macos
96+
+ );
97+
+}
98+
const ua = uaParser.getResult();
99+
100+
export const hasModulesSupport = () => {
101+
@@ -89,20 +104,10 @@ export const requireDirectAction = () => isSafari() || isFirefox() || isEdge();
102+
* @links { https://mathiasbynens.github.io/rel-noopener/}
103+
*/
104+
export const openNewTab = (url: string) => {
105+
- if (isIE11()) {
106+
- const otherWindow = window.open();
107+
- if (!otherWindow) {
108+
- return;
109+
- }
110+
- otherWindow.opener = null;
111+
- otherWindow.location.href = url;
112+
- return;
113+
- }
114+
- const anchor = document.createElement('a');
115+
-
116+
- anchor.setAttribute('rel', 'noreferrer nofollow noopener');
117+
- anchor.setAttribute('target', '_blank');
118+
- anchor.href = url;
119+
-
120+
- return anchor.click();
121+
+ window.dispatchEvent(
122+
+ new CustomEvent(
123+
+ "electron-mail:packages/shared/lib/helpers/browser.ts:openNewTab",
124+
+ {detail: {url}},
125+
+ ),
126+
+ );
127+
};
128+
129+
diff --git a/packages/components/components/link/SettingsLink.tsx b/packages/components/components/link/SettingsLink.tsx
130+
index 5081c4003..cde37c0cb 100644
131+
--- a/packages/components/components/link/SettingsLink.tsx
132+
+++ b/packages/components/components/link/SettingsLink.tsx
133+
@@ -48,7 +48,7 @@ const SettingsLink = ({ path, app, children, ...rest }: Props, ref: Ref<HTMLAnch
134+
ref={ref}
135+
toApp={APPS.PROTONACCOUNT}
136+
// If going to settings for the same app
137+
- target={canOpenInSameTab(APP_NAME, settingsApp, toSettingsForApp) ? '_self' : '_blank'}
138+
+ target={canOpenInSameTab(APP_NAME, settingsApp, toSettingsForApp) || app === APPS.PROTONVPN_SETTINGS ? '_self' : '_blank'}
139+
{...rest}
140+
>
141+
{children}
142+
143+
diff --git a/packages/components/helpers/earlyAccessDesynchronization.ts b/packages/components/helpers/earlyAccessDesynchronization.ts
144+
index 36bd0c712..c2fb3681c 100644
145+
--- a/packages/components/helpers/earlyAccessDesynchronization.ts
146+
+++ b/packages/components/helpers/earlyAccessDesynchronization.ts
147+
@@ -42,6 +42,7 @@ export const handleEarlyAccessDesynchronization = ({
148+
earlyAccessScope: Feature<Environment> | undefined;
149+
appName: APP_NAMES;
150+
}) => {
151+
+ return;
152+
if (doesNotSupportEarlyAccessVersion()) {
153+
return;
154+
}
155+
156+
diff --git a/applications/mail/src/app/components/list/banners/auto-delete/variations/AutoDeleteFreeBanner.tsx b/applications/mail/src/app/components/list/banners/auto-delete/variations/AutoDeleteFreeBanner.tsx
157+
index 24c56ef6fe..a6046b391c 100644
158+
--- a/applications/mail/src/app/components/list/banners/auto-delete/variations/AutoDeleteFreeBanner.tsx
159+
+++ b/applications/mail/src/app/components/list/banners/auto-delete/variations/AutoDeleteFreeBanner.tsx
160+
@@ -7,6 +7,10 @@ import { AutoDeleteUpsellModal, useModalState } from '@proton/components/compone
161+
import { PromotionBanner } from '@proton/components/containers';
162+
163+
const AutoDeleteFreeBanner = () => {
164+
+ if (___ELECTRON_MAIL_PROTON_SUPPRESS_UPSELL_ADS_PLACEHOLDER___) {
165+
+ return null;
166+
+ }
167+
+
168+
const [upsellModalProps, toggleUpsellModal, renderUpsellModal] = useModalState();
169+
170+
return (
171+
172+
diff --git a/applications/mail/src/app/hooks/useShowUpsellBanner.ts b/applications/mail/src/app/hooks/useShowUpsellBanner.ts
173+
index b82b7ae976..0907c85ec6 100644
174+
--- a/applications/mail/src/app/hooks/useShowUpsellBanner.ts
175+
+++ b/applications/mail/src/app/hooks/useShowUpsellBanner.ts
176+
@@ -33,12 +33,14 @@ const useShowUpsellBanner = (labelID: string) => {
177+
- No other banner is shown in the message list
178+
- If a value is found in the localStorage that should trigger a new display
179+
*/
180+
+ /* <electron-mail-mark> */
181+
const canDisplayUpsellBanner =
182+
user.isFree &&
183+
Date.now() > threeDaysAfterCreationDate &&
184+
isInbox &&
185+
needToShowUpsellBanner.current &&
186+
showAgain;
187+
+ /* </electron-mail-mark> */
188+
189+
const handleDismissBanner = () => {
190+
// Set the ref to false so that we hide the banner and update the localStorage value
191+
@@ -71,6 +73,10 @@ const useShowUpsellBanner = (labelID: string) => {
192+
}
193+
}, []);
194+
195+
+ if (___ELECTRON_MAIL_PROTON_SUPPRESS_UPSELL_ADS_PLACEHOLDER___) {
196+
+ return { canDisplayUpsellBanner: false, needToShowUpsellBanner, handleDismissBanner };
197+
+ }
198+
+
199+
return { canDisplayUpsellBanner, needToShowUpsellBanner, handleDismissBanner };
200+
};
201+
202+
diff --git a/packages/components/containers/heading/PrivateHeader.tsx b/packages/components/containers/heading/PrivateHeader.tsx
203+
index a7d2452313..73ad8a6828 100644
204+
--- a/packages/components/containers/heading/PrivateHeader.tsx
205+
+++ b/packages/components/containers/heading/PrivateHeader.tsx
206+
@@ -49,7 +49,10 @@ const PrivateHeader = ({
207+
208+
<TopNavbar>
209+
<TopNavbarList>
210+
- {upsellButton !== undefined ? upsellButton : !hideUpsellButton && <TopNavbarUpsell app={app} />}
211+
+ {___ELECTRON_MAIL_PROTON_SUPPRESS_UPSELL_ADS_PLACEHOLDER___
212+
+ ? null
213+
+ : (upsellButton !== undefined ? upsellButton : !hideUpsellButton && <TopNavbarUpsell app={app} />)
214+
+ }
215+
{feedbackButton ? <TopNavbarListItem noShrink>{feedbackButton}</TopNavbarListItem> : null}
216+
{settingsButton ? (
217+
<TopNavbarListItem noShrink className="no-mobile">
218+
219+
diff --git a/packages/components/containers/api/ApiProvider.js b/packages/components/containers/api/ApiProvider.js
220+
index 3d1b81941c..6ac2f748fa 100644
221+
--- a/packages/components/containers/api/ApiProvider.js
222+
+++ b/packages/components/containers/api/ApiProvider.js
223+
@@ -120,7 +120,9 @@ const ApiProvider = ({ config, onLogout, children, UID, noErrorState }) => {
224+
error.cancel = true;
225+
reject(error);
226+
}}
227+
- />
228+
+ />,
229+
+ // trying to force single instance, see https://github.com/vladimiry/ElectronMail/issues/621#issuecomment-1627389416
230+
+ "HumanVerificationModal_ID",
231+
);
232+
});
233+
};

patches/protonmail/meta.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"proton-mail": [
33
"common-5.patch",
44
"drop-circular-dependency-2.patch",
5-
"url-5.patch",
5+
"url-6.patch",
66
"constants-10.patch",
7-
"sentry-15.patch",
7+
"sentry-16.patch",
88
"pack-api-arg-5.patch",
99
"pack-webpack-8.patch",
1010
"session-storage-5.patch",
@@ -13,7 +13,7 @@
1313
"proton-mail.patch"
1414
],
1515
"proton-account": [
16-
"common-6.patch",
16+
"common-7.patch",
1717
"drop-circular-dependency-2.patch",
1818
"url-6.patch",
1919
"constants-10.patch",
@@ -28,9 +28,9 @@
2828
"proton-calendar": [
2929
"common-5.patch",
3030
"drop-circular-dependency-2.patch",
31-
"url-5.patch",
31+
"url-6.patch",
3232
"constants-10.patch",
33-
"sentry-15.patch",
33+
"sentry-16.patch",
3434
"pack-api-arg-5.patch",
3535
"pack-webpack-8.patch",
3636
"session-storage-5.patch",
@@ -52,7 +52,7 @@
5252
"proton-drive.patch"
5353
],
5454
"proton-vpn-settings": [
55-
"common-6.patch",
55+
"common-7.patch",
5656
"drop-circular-dependency-2.patch",
5757
"url-6.patch",
5858
"constants-10.patch",

0 commit comments

Comments
 (0)