Inline 2
This commit is contained in:
@@ -43,7 +43,6 @@ import ArrowForward from "@mui/icons-material/ArrowForward";
|
||||
import { CssBaseline } from "@mui/material";
|
||||
import { ThemeProvider } from "@mui/material/styles";
|
||||
import Notification from "components/Notification";
|
||||
import { REDIRECTS } from "constants/redirects";
|
||||
import { t } from "i18next";
|
||||
import isElectron from "is-electron";
|
||||
import type { AppProps } from "next/app";
|
||||
@@ -67,8 +66,6 @@ import {
|
||||
getUpdateReadyToInstallMessage,
|
||||
} from "utils/ui";
|
||||
|
||||
const redirectMap = new Map([[REDIRECTS.FAMILIES, getFamilyPortalRedirectURL]]);
|
||||
|
||||
/**
|
||||
* Properties available via {@link AppContext} to the Photos app's React tree.
|
||||
*/
|
||||
@@ -202,25 +199,17 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
const setUserOnline = () => setOffline(false);
|
||||
const setUserOffline = () => setOffline(true);
|
||||
|
||||
useEffect(() => {
|
||||
const redirectTo = async (redirect) => {
|
||||
if (
|
||||
redirectMap.has(redirect) &&
|
||||
typeof redirectMap.get(redirect) === "function"
|
||||
) {
|
||||
const redirectAction = redirectMap.get(redirect);
|
||||
window.location.href = await redirectAction();
|
||||
} else {
|
||||
log.error(`invalid redirection ${redirect}`);
|
||||
}
|
||||
};
|
||||
const redirectToFamilyPortal = void getFamilyPortalRedirectURL().then(
|
||||
(url) => (window.location.href = url),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
const redirectName = query.get("redirect");
|
||||
if (redirectName) {
|
||||
if (redirectName == "families") {
|
||||
const user = getData(LS_KEYS.USER);
|
||||
if (user?.token) {
|
||||
redirectTo(redirectName);
|
||||
redirectToFamilyPortal();
|
||||
} else {
|
||||
setRedirectName(redirectName);
|
||||
}
|
||||
@@ -235,7 +224,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
if (redirectName) {
|
||||
const user = getData(LS_KEYS.USER);
|
||||
if (user?.token) {
|
||||
redirectTo(redirectName);
|
||||
redirectToFamilyPortal();
|
||||
|
||||
// https://github.com/vercel/next.js/issues/2476#issuecomment-573460710
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import log from "@/base/log";
|
||||
import { openURL } from "@/new/photos/utils/web";
|
||||
import { SetDialogBoxAttributes } from "@ente/shared/components/DialogBox/types";
|
||||
import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
|
||||
import { t } from "i18next";
|
||||
@@ -246,25 +245,6 @@ export async function updatePaymentMethod(
|
||||
}
|
||||
}
|
||||
|
||||
export async function manageFamilyMethod(
|
||||
setDialogMessage: SetDialogBoxAttributes,
|
||||
setLoading: SetLoading,
|
||||
) {
|
||||
try {
|
||||
setLoading(true);
|
||||
;
|
||||
} catch (e) {
|
||||
log.error("failed to redirect to family portal", e);
|
||||
setDialogMessage({
|
||||
title: t("ERROR"),
|
||||
content: t("UNKNOWN_ERROR"),
|
||||
close: { variant: "critical" },
|
||||
});
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkSubscriptionPurchase(
|
||||
setDialogMessage: SetDialogBoxAttributes,
|
||||
router: NextRouter,
|
||||
|
||||
Reference in New Issue
Block a user