Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Improve load experience (#1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkgrd committed Apr 24, 2023
2 parents dacd703 + f0703d2 commit e24c16d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
15 changes: 2 additions & 13 deletions src/components/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import React from 'react';
import { useRouter } from 'next/router';
import { sendOtt } from 'services/userService';
import { setData, LS_KEYS, getData } from 'utils/storage/localStorage';
import { setData, LS_KEYS } from 'utils/storage/localStorage';
import { PAGES } from 'constants/pages';
import FormPaperTitle from './Form/FormPaper/Title';
import FormPaperFooter from './Form/FormPaper/Footer';
Expand All @@ -17,17 +17,6 @@ interface LoginProps {
export default function Login(props: LoginProps) {
const router = useRouter();

useEffect(() => {
const main = async () => {
router.prefetch(PAGES.VERIFY);
const user = getData(LS_KEYS.USER);
if (user?.email) {
await router.push(PAGES.VERIFY);
}
};
main();
}, []);

const loginUser: SingleInputFormProps['callback'] = async (
email,
setFieldError
Expand Down
18 changes: 12 additions & 6 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import AppNavbar from 'components/Navbar/app';
import { t } from 'i18next';

import { useRouter } from 'next/router';
import VerticallyCentered from 'components/Container';
import { Overlay } from 'components/Container';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'photoswipe/dist/photoswipe.css';
import 'styles/global.css';
Expand Down Expand Up @@ -456,15 +456,21 @@ export default function App(props) {
somethingWentWrong,
setDialogBoxAttributesV2,
}}>
{loading || !isI18nReady ? (
<VerticallyCentered>
{(loading || !isI18nReady) && (
<Overlay
sx={(theme) => ({
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
zIndex: 2000,
backgroundColor: theme.colors.background.base,
})}>
<EnteSpinner>
<span className="sr-only">Loading...</span>
</EnteSpinner>
</VerticallyCentered>
) : (
<Component setLoading={setLoading} {...pageProps} />
</Overlay>
)}
<Component setLoading={setLoading} {...pageProps} />
</AppContext.Provider>
</ThemeProvider>
</CacheProvider>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/change-password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function ChangePassword() {
callback={onSubmit}
buttonText={t('CHANGE_PASSWORD')}
/>
{getData(LS_KEYS.SHOW_BACK_BUTTON)?.value && (
{(getData(LS_KEYS.SHOW_BACK_BUTTON)?.value ?? true) && (
<FormPaperFooter>
<LinkButton onClick={router.back}>
{t('GO_BACK')}
Expand Down

0 comments on commit e24c16d

Please sign in to comment.