Inline
This commit is contained in:
@@ -23,7 +23,6 @@ import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
|
||||
import type { DialogBoxAttributesV2 } from "@ente/shared/components/DialogBoxV2/types";
|
||||
import EnteSpinner from "@ente/shared/components/EnteSpinner";
|
||||
import { MessageContainer } from "@ente/shared/components/MessageContainer";
|
||||
import { PHOTOS_PAGES as PAGES } from "@ente/shared/constants/pages";
|
||||
import { useLocalState } from "@ente/shared/hooks/useLocalState";
|
||||
import HTTPService from "@ente/shared/network/HTTPService";
|
||||
import {
|
||||
@@ -102,7 +101,6 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
typeof window !== "undefined" && !window.navigator.onLine,
|
||||
);
|
||||
const [showNavbar, setShowNavBar] = useState(false);
|
||||
const [redirectName, setRedirectName] = useState<string>(null);
|
||||
const [mapEnabled, setMapEnabled] = useState(false);
|
||||
const isLoadingBarRunning = useRef(false);
|
||||
const loadingBar = useRef(null);
|
||||
@@ -199,37 +197,24 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
const setUserOnline = () => setOffline(false);
|
||||
const setUserOffline = () => setOffline(true);
|
||||
|
||||
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 == "families") {
|
||||
const user = getData(LS_KEYS.USER);
|
||||
if (user?.token) {
|
||||
redirectToFamilyPortal();
|
||||
} else {
|
||||
setRedirectName(redirectName);
|
||||
}
|
||||
}
|
||||
const needsFamilyRedirect = query.get("redirect") == "families";
|
||||
if (needsFamilyRedirect && getData(LS_KEYS.USER)?.token)
|
||||
redirectToFamilyPortal();
|
||||
|
||||
router.events.on("routeChangeStart", (url: string) => {
|
||||
const newPathname = url.split("?")[0] as PAGES;
|
||||
const newPathname = url.split("?")[0];
|
||||
if (window.location.pathname !== newPathname) {
|
||||
setLoading(true);
|
||||
}
|
||||
|
||||
if (redirectName) {
|
||||
const user = getData(LS_KEYS.USER);
|
||||
if (user?.token) {
|
||||
redirectToFamilyPortal();
|
||||
if (needsFamilyRedirect && getData(LS_KEYS.USER)?.token) {
|
||||
redirectToFamilyPortal();
|
||||
|
||||
// https://github.com/vercel/next.js/issues/2476#issuecomment-573460710
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw "Aborting route change, redirection in process....";
|
||||
}
|
||||
// https://github.com/vercel/next.js/issues/2476#issuecomment-573460710
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw "Aborting route change, redirection in process....";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -244,7 +229,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
window.removeEventListener("online", setUserOnline);
|
||||
window.removeEventListener("offline", setUserOffline);
|
||||
};
|
||||
}, [redirectName]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setMessageDialogView(true);
|
||||
@@ -373,3 +358,8 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const redirectToFamilyPortal = () =>
|
||||
void getFamilyPortalRedirectURL().then((url) => {
|
||||
window.location.href = url;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user