From 8ffa84779da00cdd8a7ed08af1c01a30d5280736 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Mon, 11 Jul 2022 23:48:39 +0530 Subject: [PATCH] directly go to gallery if key present --- src/pages/index.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f92404ac5..66445e68d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -12,6 +12,10 @@ import localForage from 'utils/storage/localForage'; import { logError } from 'utils/sentry'; import { getAlbumSiteHost, PAGES } from 'constants/pages'; import { EnteLogo } from 'components/EnteLogo'; +import isElectron from 'is-electron'; +import desktopService from 'services/desktopService'; +import { saveKeyInSessionStore } from 'utils/crypto'; +import { getKey, SESSION_KEYS } from 'utils/storage/sessionStorage'; const Container = styled('div')` display: flex; @@ -122,7 +126,20 @@ export default function LandingPage() { const handleNormalRedirect = async () => { const user = getData(LS_KEYS.USER); - if (user?.email) { + let key = getKey(SESSION_KEYS.ENCRYPTION_KEY); + if (!key && isElectron()) { + key = await desktopService.getEncryptionKey(); + if (key) { + await saveKeyInSessionStore( + SESSION_KEYS.ENCRYPTION_KEY, + key, + true + ); + } + } + if (key) { + await router.push(PAGES.GALLERY); + } else if (user?.email) { await router.push(PAGES.VERIFY); } await initLocalForage();