Skip to content

Commit

Permalink
Add platform to download urls
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Sep 27, 2023
1 parent 0377ffd commit 6fa03a3
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
3 changes: 1 addition & 2 deletions gui/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"purchase": "https://mullvad.net/account/",
"faq": "https://mullvad.net/help/tag/mullvad-app/",
"privacyGuide": "https://mullvad.net/help/first-steps-towards-online-privacy/",
"download": "https://mullvad.net/download/",
"betaDownload": "https://mullvad.net/download/beta"
"download": "https://mullvad.net/download/"
},
"colors": {
"darkBlue": "rgb(25, 46, 69)",
Expand Down
4 changes: 2 additions & 2 deletions gui/src/renderer/components/ProblemReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
useState,
} from 'react';

import { links } from '../../config.json';
import { messages } from '../../shared/gettext';
import { getDownloadUrl } from '../../shared/version';
import { useAppContext } from '../context';
import useActions from '../lib/actionsHook';
import { useHistory } from '../lib/history';
Expand Down Expand Up @@ -326,7 +326,7 @@ function OutdatedVersionWarningDialog() {
}, []);

const openDownloadLink = useCallback(async () => {
await openUrl(suggestedIsBeta ? links.betaDownload : links.download);
await openUrl(getDownloadUrl(suggestedIsBeta));
}, [suggestedIsBeta]);

const onClose = useCallback(() => history.pop(), [history.pop]);
Expand Down
11 changes: 6 additions & 5 deletions gui/src/renderer/components/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback } from 'react';

import { colors, links } from '../../config.json';
import { colors } from '../../config.json';
import { messages } from '../../shared/gettext';
import { getDownloadUrl } from '../../shared/version';
import { useAppContext } from '../context';
import { useHistory } from '../lib/history';
import { RoutePath } from '../lib/routes';
Expand Down Expand Up @@ -148,10 +149,10 @@ function AppVersionButton() {
const isOffline = useSelector((state) => state.connection.isBlocked);

const { openUrl } = useAppContext();
const openDownloadLink = useCallback(
() => openUrl(suggestedIsBeta ? links.betaDownload : links.download),
[openUrl, suggestedIsBeta],
);
const openDownloadLink = useCallback(() => openUrl(getDownloadUrl(suggestedIsBeta)), [
openUrl,
suggestedIsBeta,
]);

let icon;
let footer;
Expand Down
6 changes: 3 additions & 3 deletions gui/src/shared/notifications/unsupported-version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { links } from '../../config.json';
import { messages } from '../../shared/gettext';
import { getDownloadUrl } from '../version';
import {
InAppNotification,
InAppNotificationProvider,
Expand Down Expand Up @@ -31,7 +31,7 @@ export class UnsupportedVersionNotificationProvider
severity: SystemNotificationSeverityType.high,
action: {
type: 'open-url',
url: this.context.suggestedIsBeta ? links.betaDownload : links.download,
url: getDownloadUrl(this.context.suggestedIsBeta ?? false),
text: messages.pgettext('notifications', 'Upgrade'),
},
presentOnce: { value: true, name: this.constructor.name },
Expand All @@ -46,7 +46,7 @@ export class UnsupportedVersionNotificationProvider
subtitle: this.getMessage(),
action: {
type: 'open-url',
url: this.context.suggestedIsBeta ? links.betaDownload : links.download,
url: getDownloadUrl(this.context.suggestedIsBeta ?? false),
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions gui/src/shared/notifications/update-available.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sprintf } from 'sprintf-js';

import { links } from '../../config.json';
import { messages } from '../../shared/gettext';
import { getDownloadUrl } from '../version';
import {
InAppNotification,
InAppNotificationProvider,
Expand Down Expand Up @@ -33,7 +33,7 @@ export class UpdateAvailableNotificationProvider
subtitle: this.inAppMessage(),
action: {
type: 'open-url',
url: this.context.suggestedIsBeta ? links.betaDownload : links.download,
url: getDownloadUrl(this.context.suggestedIsBeta ?? false),
},
};
}
Expand All @@ -45,7 +45,7 @@ export class UpdateAvailableNotificationProvider
severity: SystemNotificationSeverityType.medium,
action: {
type: 'open-url',
url: this.context.suggestedIsBeta ? links.betaDownload : links.download,
url: getDownloadUrl(this.context.suggestedIsBeta ?? false),
text: messages.pgettext('notifications', 'Upgrade'),
},
presentOnce: { value: true, name: this.constructor.name },
Expand Down
22 changes: 22 additions & 0 deletions gui/src/shared/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { links } from '../config.json';

export function getDownloadUrl(suggestedIsBeta: boolean): string {
let url = links.download;
switch (process.platform ?? window.env.platform) {
case 'win32':
url += 'windows/';
break;
case 'linux':
url += 'linux/';
break;
case 'darwin':
url += 'macos/';
break;
}

if (suggestedIsBeta) {
url += 'beta/';
}

return url;
}

0 comments on commit 6fa03a3

Please sign in to comment.