Просмотр исходного кода

Merge pull request #550 from smiclea/fix-admin-load

Fix page load stuck at "Checking Permissions..."
Nashwan Azhari 5 лет назад
Родитель
Сommit
bf9913ca05
1 измененных файлов с 1 добавлено и 15 удалено
  1. 1 15
      src/components/App.jsx

+ 1 - 15
src/components/App.jsx

@@ -47,7 +47,6 @@ import { navigationMenu } from '../constants'
 import Palette from './styleUtils/Palette'
 import StyleProps from './styleUtils/StyleProps'
 import configLoader from '../utils/Config'
-import ObjectUtils from '../utils/ObjectUtils'
 
 injectGlobal`
   ${Fonts}
@@ -80,7 +79,6 @@ const Wrapper = styled.div`
 type State = {
   isConfigReady: boolean,
 }
-const MIN_WAIT_MS = 0
 
 class App extends React.Component<{}, State> {
   state = {
@@ -89,24 +87,12 @@ class App extends React.Component<{}, State> {
   awaitingRefresh: boolean = false
 
   async componentWillMount() {
-    let startTime = new Date().getTime()
-    observe(userStore, 'loggedUser', () => { this.refreshState(startTime) })
+    observe(userStore, 'loggedUser', () => { this.setState({}) })
     await configLoader.load()
     userStore.tokenLogin()
     this.setState({ isConfigReady: true })
   }
 
-  async refreshState(startTime: number) {
-    if (this.awaitingRefresh) {
-      return
-    }
-    this.awaitingRefresh = true
-    if (new Date().getTime() - startTime < MIN_WAIT_MS) {
-      await ObjectUtils.wait(MIN_WAIT_MS)
-    }
-    this.setState({})
-  }
-
   render() {
     if (!this.state.isConfigReady) {
       return null