mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-11 14:53:55 +08:00
Added new search bar shortcut. Fixed bug with forms still being visible after logout. Fixed bug with config fetching order
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
||||
import { actionCreators } from './store';
|
||||
import { autoLogin, getConfig } from './store/action-creators';
|
||||
import { actionCreators, store } from './store';
|
||||
import 'external-svg-loader';
|
||||
|
||||
// Utils
|
||||
@@ -15,23 +16,20 @@ import { useDispatch } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
// Get config
|
||||
store.dispatch<any>(getConfig());
|
||||
|
||||
// Validate token
|
||||
if (localStorage.token) {
|
||||
store.dispatch<any>(autoLogin());
|
||||
}
|
||||
|
||||
export const App = (): JSX.Element => {
|
||||
const dispath = useDispatch();
|
||||
const {
|
||||
fetchQueries,
|
||||
getConfig,
|
||||
setTheme,
|
||||
logout,
|
||||
createNotification,
|
||||
autoLogin,
|
||||
} = bindActionCreators(actionCreators, dispath);
|
||||
const { fetchQueries, setTheme, logout, createNotification } =
|
||||
bindActionCreators(actionCreators, dispath);
|
||||
|
||||
useEffect(() => {
|
||||
// login if token exists
|
||||
if (localStorage.token) {
|
||||
autoLogin();
|
||||
}
|
||||
|
||||
// check if token is valid
|
||||
const tokenIsValid = setInterval(() => {
|
||||
if (localStorage.token) {
|
||||
@@ -48,9 +46,6 @@ export const App = (): JSX.Element => {
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
// load app config
|
||||
getConfig();
|
||||
|
||||
// set theme
|
||||
if (localStorage.theme) {
|
||||
setTheme(localStorage.theme);
|
||||
|
||||
Reference in New Issue
Block a user