Skip to content

Commit

Permalink
Rename open link functions to open url
Browse files Browse the repository at this point in the history
  • Loading branch information
olmoh authored and MarkusPettersson98 committed Feb 3, 2025
1 parent e5dd6b2 commit 99b30c4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion desktop/packages/mullvad-vpn/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ class ApplicationMain

IpcMainEventChannel.app.handleQuit(() => this.disconnectAndQuit());
IpcMainEventChannel.app.handleOpenUrl(async (url) => {
if (Object.values(urls).find((link) => url.startsWith(link))) {
if (Object.values(urls).find((allowedUrl) => url.startsWith(allowedUrl))) {
await shell.openExternal(url);
}
});
Expand Down
4 changes: 2 additions & 2 deletions desktop/packages/mullvad-vpn/src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,15 @@ export default class AppRenderer {
return devices;
};

public openLinkWithAuth = async (link: Url): Promise<void> => {
public openUrlWithAuth = async (url: Url): Promise<void> => {
let token = '';
try {
token = await IpcRendererEventChannel.account.getWwwAuthToken();
} catch (e) {
const error = e as Error;
log.error(`Failed to get the WWW auth token: ${error.message}`);
}
void this.openUrl(`${link}?token=${token}`);
void this.openUrl(`${url}?token=${token}`);
};

public setAllowLan = async (allowLan: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import SettingsHeader, { HeaderTitle } from './SettingsHeader';
export default function Account() {
const history = useHistory();
const isOffline = useSelector((state) => state.connection.isBlocked);
const { updateAccountData, openLinkWithAuth, logout } = useAppContext();
const { updateAccountData, openUrlWithAuth, logout } = useAppContext();

const onBuyMore = useCallback(async () => {
await openLinkWithAuth(urls.purchase);
}, [openLinkWithAuth]);
await openUrlWithAuth(urls.purchase);
}, [openUrlWithAuth]);

const onMount = useEffectEvent(() => updateAccountData());
useEffect(() => onMount(), []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function Content() {
function ExternalPaymentButton() {
const { setShowBlockWhenDisconnectedAlert } = useExpiredAccountContext();
const { recoveryAction } = useRecoveryAction();
const { openLinkWithAuth } = useAppContext();
const { openUrlWithAuth } = useAppContext();
const isNewAccount = useIsNewAccount();

const buttonText = isNewAccount
Expand All @@ -188,9 +188,9 @@ function ExternalPaymentButton() {
if (recoveryAction === RecoveryAction.disableBlockedWhenDisconnected) {
setShowBlockWhenDisconnectedAlert(true);
} else {
await openLinkWithAuth(urls.purchase);
await openUrlWithAuth(urls.purchase);
}
}, [openLinkWithAuth, recoveryAction, setShowBlockWhenDisconnectedAlert]);
}, [openUrlWithAuth, recoveryAction, setShowBlockWhenDisconnectedAlert]);

return (
<AppButton.BlockingButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function NotificationActionWrapper({
setIsModalOpen,
}: NotificationActionWrapperProps) {
const { push } = useHistory();
const { openLinkWithAuth, openUrl } = useAppContext();
const { openUrlWithAuth, openUrl } = useAppContext();

const closeTroubleshootModal = useCallback(() => setIsModalOpen(false), [setIsModalOpen]);

Expand All @@ -193,7 +193,7 @@ function NotificationActionWrapper({
switch (action.type) {
case 'open-url':
if (action.withAuth) {
return openLinkWithAuth(action.url);
return openUrlWithAuth(action.url);
} else {
return openUrl(action.url);
}
Expand All @@ -207,7 +207,7 @@ function NotificationActionWrapper({
}

return Promise.resolve();
}, [action, setIsModalOpen, openLinkWithAuth, openUrl]);
}, [action, setIsModalOpen, openUrlWithAuth, openUrl]);

const goToProblemReport = useCallback(() => {
closeTroubleshootModal();
Expand Down

0 comments on commit 99b30c4

Please sign in to comment.