From c01a827e00c610d8a100a05f838cdfc238b269a3 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 23 May 2021 21:24:45 +0530 Subject: [PATCH 1/4] moved whole useEffect inside async main --- src/pages/generate/index.tsx | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/pages/generate/index.tsx b/src/pages/generate/index.tsx index 6910c1f4c..f264e7410 100644 --- a/src/pages/generate/index.tsx +++ b/src/pages/generate/index.tsx @@ -26,20 +26,20 @@ export default function Generate(props) { const [recoverModalView, setRecoveryModalView] = useState(false); useEffect(() => { - props.setLoading(true); - const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); - const keyAttributes: KeyAttributes = getData( - LS_KEYS.ORIGINAL_KEY_ATTRIBUTES - ); - router.prefetch('/gallery'); - const user = getData(LS_KEYS.USER); - if (!user?.token) { - router.push('/'); - return; - } - setToken(user.token); - if (keyAttributes?.encryptedKey) { - const main = async () => { + const main = async () => { + props.setLoading(true); + const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); + const keyAttributes: KeyAttributes = getData( + LS_KEYS.ORIGINAL_KEY_ATTRIBUTES + ); + router.prefetch('/gallery'); + const user = getData(LS_KEYS.USER); + if (!user?.token) { + router.push('/'); + return; + } + setToken(user.token); + if (keyAttributes?.encryptedKey) { try { await putAttributes(user.token, keyAttributes); } catch (e) { @@ -47,12 +47,12 @@ export default function Generate(props) { } setData(LS_KEYS.ORIGINAL_KEY_ATTRIBUTES, null); setRecoveryModalView(true); - }; - main(); - } else if (key) { - router.push('/gallery'); - } - props.setLoading(false); + } else if (key) { + router.push('/gallery'); + } + props.setLoading(false); + }; + main(); }, []); const onSubmit = async (passphrase, setFieldError) => { From 65b034c62ad6b43445d36c7eda301ba4a4bd8de0 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 23 May 2021 21:27:17 +0530 Subject: [PATCH 2/4] removed understood check --- src/pages/signup/index.tsx | 12 +----------- src/utils/strings/englishConstants.tsx | 4 ++-- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/pages/signup/index.tsx b/src/pages/signup/index.tsx index 4f7b172c0..6d7ec8a79 100644 --- a/src/pages/signup/index.tsx +++ b/src/pages/signup/index.tsx @@ -169,20 +169,10 @@ export default function SignUp() { label={constants.TERMS_AND_CONDITIONS()} /> - - - setUnderstood(e.target.checked) - } - type="checkbox" - label={constants.CONFIRM_PASSWORD_NOT_SAVED()} - /> - )} diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 4b6dd8e7b..32068f188 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -303,9 +303,9 @@ const englishConstants = { CREATE_ALBUM_FAILED: 'failed to create album , please try again', TERMS_AND_CONDITIONS: () => (

- i agree to the{' '} + I agree to the{' '} - terms of service + terms {' '} and{' '} From 8fc27abe6c89d33da909eef795f082a39dc8639b Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 23 May 2021 22:24:14 +0530 Subject: [PATCH 3/4] updated generate page --- src/pages/generate/index.tsx | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/pages/generate/index.tsx b/src/pages/generate/index.tsx index f264e7410..8f0ea724f 100644 --- a/src/pages/generate/index.tsx +++ b/src/pages/generate/index.tsx @@ -13,6 +13,8 @@ import SetPasswordForm from 'components/SetPasswordForm'; import { setJustSignedUp } from 'utils/storage'; import RecoveryKeyModal from 'components/RecoveryKeyModal'; import { KeyAttributes } from 'types'; +import Container from 'components/Container'; +import EnteSpinner from 'components/EnteSpinner'; export interface KEK { key: string; @@ -24,10 +26,10 @@ export default function Generate(props) { const [token, setToken] = useState(); const router = useRouter(); const [recoverModalView, setRecoveryModalView] = useState(false); - + const [loading, setLoading] = useState(false); useEffect(() => { const main = async () => { - props.setLoading(true); + setLoading(true); const key = getKey(SESSION_KEYS.ENCRYPTION_KEY); const keyAttributes: KeyAttributes = getData( LS_KEYS.ORIGINAL_KEY_ATTRIBUTES @@ -50,7 +52,7 @@ export default function Generate(props) { } else if (key) { router.push('/gallery'); } - props.setLoading(false); + setLoading(false); }; main(); }, []); @@ -78,21 +80,28 @@ export default function Generate(props) { return ( <> - {!recoverModalView && ( + {loading ? ( + + + Loading... + + + ) : recoverModalView ? ( + { + setRecoveryModalView(false); + router.push('/gallery'); + }} + somethingWentWrong={() => null} + /> + ) : ( )} - { - setRecoveryModalView(false); - router.push('/gallery'); - }} - somethingWentWrong={() => null} - /> ); } From 695cdf58ddcda806fe9dd8b17d9b6caebf5a88d1 Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Sun, 23 May 2021 22:25:48 +0530 Subject: [PATCH 4/4] updated sinup page style --- src/pages/signup/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/signup/index.tsx b/src/pages/signup/index.tsx index 6d7ec8a79..039dd6889 100644 --- a/src/pages/signup/index.tsx +++ b/src/pages/signup/index.tsx @@ -155,9 +155,11 @@ export default function SignUp() { {errors.confirm} -
+