Merge pull request #602 from ente-io/open-family-new-window

open family page in new tab
This commit is contained in:
Abhinav Kumar 2022-06-16 17:40:21 +05:30 committed by GitHub
commit a5f093456f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import { CustomError } from '../error';
import { logError } from '../sentry';
import { getFamilyPortalRedirectURL } from 'services/userService';
import { FamilyData, FamilyMember, User } from 'types/user';
import { openLink } from 'utils/common';
const PAYMENT_PROVIDER_STRIPE = 'stripe';
const PAYMENT_PROVIDER_APPSTORE = 'appstore';
@ -253,15 +254,16 @@ export async function manageFamilyMethod(
try {
setLoading(true);
const url = await getFamilyPortalRedirectURL();
window.location.href = url;
openLink(url, true);
} catch (error) {
logError(error, 'failed to redirect to family portal');
setLoading(false);
setDialogMessage({
title: constants.ERROR,
content: constants.UNKNOWN_ERROR,
close: { variant: 'danger' },
});
} finally {
setLoading(false);
}
}

View file

@ -69,3 +69,13 @@ export const promiseWithTimeout = async (
rejectOnTimeout,
]);
};
export function openLink(href: string, newTab?: boolean) {
const a = document.createElement('a');
a.href = href;
if (newTab) {
a.target = '_blank';
}
a.rel = 'noreferrer noopener';
a.click();
}