diff --git a/src/compose.jsx b/src/compose.jsx index 47545066..296c74fc 100644 --- a/src/compose.jsx +++ b/src/compose.jsx @@ -9,8 +9,10 @@ import { render } from 'preact'; import { useEffect, useState } from 'preact/hooks'; import ComposeSuspense from './components/compose-suspense'; +import Loader from './components/loader'; import { initActivateLang } from './utils/lang'; import { initStates } from './utils/states'; +import { getCurrentAccount, setCurrentAccountID } from './utils/store-utils'; import useTitle from './utils/useTitle'; initActivateLang(); @@ -21,6 +23,7 @@ if (window.opener) { function App() { const [uiState, setUIState] = useState('default'); + const [isLoggedIn, setIsLoggedIn] = useState(null); const { editStatus, replyToStatus, draftStatus } = window.__COMPOSE__ || {}; @@ -35,7 +38,11 @@ function App() { ); useEffect(() => { - initStates(); + const account = getCurrentAccount(); + setIsLoggedIn(!!account); + if (account) { + initStates(); + } }, []); useEffect(() => { @@ -69,24 +76,50 @@ function App() { console.debug('OPEN COMPOSE'); + if (isLoggedIn === false) { + return ( +
+ ); + } + + if (isLoggedIn) { + return ( +