From dde84402e7b56de3ed7b487c2cfb4d943bff42e9 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 8 Aug 2020 16:19:43 +0800 Subject: Wait for localforage ready. --- Timeline/ClientApp/src/app/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Timeline/ClientApp/src') diff --git a/Timeline/ClientApp/src/app/App.tsx b/Timeline/ClientApp/src/app/App.tsx index 03775275..31ff9a4e 100644 --- a/Timeline/ClientApp/src/app/App.tsx +++ b/Timeline/ClientApp/src/app/App.tsx @@ -12,6 +12,7 @@ import User from './user/User'; import TimelinePage from './timeline/TimelinePage'; import AlertHost from './common/AlertHost'; +import { dataStorage } from './data/common'; import { userService, useRawUser } from './data/user'; const NoMatch: React.FC = () => { @@ -29,14 +30,17 @@ const LazyAdmin = React.lazy(() => ); const App: React.FC = () => { + const [loading, setLoading] = React.useState(true); + const user = useRawUser(); React.useEffect(() => { void userService.checkLoginState(); + void dataStorage.ready().then(() => setLoading(false)); }, []); let body; - if (user === undefined) { + if (user === undefined || loading) { body = ; } else { body = ( -- cgit v1.2.3