diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d01058..7e651e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - add a service worker for basic caching - 1.4.1 fix service worker location and working - 1.4.2 add offline view with last books stored in local storage +- 1.4.3 start offline when not online, highlight the offline state ## 1.3.0 Add lists by title (2023-01-05) diff --git a/src/js/components/App.tsx b/src/js/components/App.tsx index 27da2dd..7b0be18 100644 --- a/src/js/components/App.tsx +++ b/src/js/components/App.tsx @@ -64,7 +64,9 @@ export default function App(): JSX.Element { function AppInsideRouter(): JSX.Element { // state for application - const [state, setState] = React.useState(AppState.starting); + const [state, setState] = React.useState( + navigator.onLine ? AppState.starting : AppState.loggedOut, + ); const [customMessage, setCustomMessage] = React.useState(''); const [email, setEmail] = React.useState(); const [bookTemplate, setBookTemplate] = React.useState>({}); diff --git a/src/js/components/Login.tsx b/src/js/components/Login.tsx index 3f27991..0ea7ef8 100644 --- a/src/js/components/Login.tsx +++ b/src/js/components/Login.tsx @@ -52,13 +52,11 @@ export default function Login({ state, setState }: LoginProps): JSX.Element { let mainEl: JSX.Element; switch (state) { case AppState.starting: - case AppState.offline: case AppState.loggedOut: - mainEl = ( - - ); + mainEl = ; + break; + case AppState.offline: + mainEl = ; break; case AppState.loggedIn: case AppState.progress: