mirror of
1
Fork 0

only do API checks on logged-in state

This commit is contained in:
f0x 2022-09-15 17:27:32 +02:00
parent fac0e28afb
commit 02ac28e832
1 changed files with 24 additions and 24 deletions

View File

@ -58,6 +58,7 @@ function App() {
const [ tokenChecked, setTokenChecked ] = React.useState(false);
React.useEffect(() => {
if (loginState == "login" || loginState == "callback") {
Promise.try(() => {
// Process OAUTH authorization token from URL if available
if (loginState == "callback") {
@ -75,15 +76,14 @@ function App() {
return dispatch(api.instance.fetch());
}).then(() => {
// Check currently stored auth token for validity if available
if (loginState == "callback" || loginState == "login") {
return dispatch(api.user.fetchAccount());
}
}).then(() => {
setTokenChecked(true);
}).catch((e) => {
setErrorMsg(e);
console.error(e.message);
});
}
}, []);
let ErrorElement = null;