Bladeren bron

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 jaren geleden
bovenliggende
commit
5467be1b2f
1 gewijzigde bestanden met toevoegingen van 4 en 1 verwijderingen
  1. 4 1
      src/components/pages/ReplicasPage/index.jsx

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

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