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

Fix replicas page polling issue in rare situation

Rarely, when the browser is redirected from replicas page (ie due to
token expiration), the replicas polling would continue in the
background.
Sergiu Miclea 8 лет назад
Родитель
Сommit
5467be1b2f
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/components/pages/ReplicasPage/index.jsx

+ 4 - 1
src/components/pages/ReplicasPage/index.jsx

@@ -53,6 +53,7 @@ type State = {
 @observer
 class ReplicasPage extends React.Component<{}, State> {
   pollTimeout: TimeoutID
+  stopPolling: boolean
 
   constructor() {
     super()
@@ -70,11 +71,13 @@ class ReplicasPage extends React.Component<{}, State> {
     ProjectStore.getProjects()
     EndpointStore.getEndpoints()
 
+    this.stopPolling = false
     this.pollData()
   }
 
   componentWillUnmount() {
     clearTimeout(this.pollTimeout)
+    this.stopPolling = true
   }
 
   getEndpoint(endpointId: string) {
@@ -169,7 +172,7 @@ class ReplicasPage extends React.Component<{}, State> {
   }
 
   pollData() {
-    if (this.state.modalIsOpen) {
+    if (this.state.modalIsOpen || this.stopPolling) {
       return
     }
     ReplicaStore.getReplicas().then(() => {