diff --git a/simplq/src/components/Layout/Layout.jsx b/simplq/src/components/Layout/Layout.jsx
index bde01a0f..1de535c2 100644
--- a/simplq/src/components/Layout/Layout.jsx
+++ b/simplq/src/components/Layout/Layout.jsx
@@ -1,9 +1,9 @@
import React, { useEffect } from 'react';
+import { useGetUserQueues } from 'store/asyncActions';
+import { useDispatch } from 'react-redux';
import { useAuth0 } from '@auth0/auth0-react';
import Footer from 'components/common/Footer';
import Loading from 'components/common/Loading/Loading';
-import { useGetUserQueues } from 'store/asyncActions';
-import { useDispatch } from 'react-redux';
import Routes from './Routes';
import styles from './Layout.module.scss';
@@ -13,8 +13,8 @@ function Layout() {
const getUserQueues = useGetUserQueues();
useEffect(() => {
- // TODO: Server still returns queues for anonymous users
- // Dispatch action only if auth is loaded
+ // All the backend API calls that should happen at the start goes here.
+ // They will the dispached as soon as Auth0 has initilised.
if (isLoading === false) {
dispatch(getUserQueues());
}
@@ -23,8 +23,8 @@ function Layout() {
return (
- {/* TODO: Since we have better way for managing loading status
- remove conditional loading of the layout once it is handled elswhere */}
+ {/* We load the main app content only after Auth0 has been initilised.
+ This helps ensure that no backend API calls are made before auth the initilisation */}
diff --git a/simplq/src/components/common/ClickableLogo/ClickableLogo.jsx b/simplq/src/components/common/ClickableLogo/ClickableLogo.jsx
index c299799e..4106b381 100644
--- a/simplq/src/components/common/ClickableLogo/ClickableLogo.jsx
+++ b/simplq/src/components/common/ClickableLogo/ClickableLogo.jsx
@@ -8,8 +8,7 @@ import styles from './ClickableLogo.module.scss';
export default (props) => {
const history = useHistory();
const defaultOnClick = () => {
- history.push('/');
- smoothScrollToHomePageTop();
+ smoothScrollToHomePageTop(history);
};
return (
diff --git a/simplq/src/components/common/Nav/LeftNav.jsx b/simplq/src/components/common/Nav/LeftNav.jsx
index de72e132..89e74975 100644
--- a/simplq/src/components/common/Nav/LeftNav.jsx
+++ b/simplq/src/components/common/Nav/LeftNav.jsx
@@ -1,11 +1,14 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import React from 'react';
-import { smoothScrollTo } from 'utils/scrollingOperations';
+import { smoothScrollTo, smoothScrollToHomePageTop, onLoadById } from 'utils/scrollingOperations';
+import { useHistory } from 'react-router';
import styles from './Nav.module.scss';
import LoginButton from '../LoginButton';
const LeftNav = ({ open, toggleClose }) => {
+ const history = useHistory();
+
const scrollToHowItWorks = () => {
// Close the navbar on click
toggleClose();
@@ -15,14 +18,21 @@ const LeftNav = ({ open, toggleClose }) => {
// element is on the current page, just have to scroll to it
smoothScrollTo(element);
} else {
- window.location.href = '/#target_how_it_works';
+ history.push('/');
+ // wait till page loads before getting element
+ onLoadById('target_how_it_works', smoothScrollTo);
}
};
return (