Parcourir la source

Fix endpoint fields reverting to previous values

Sometimes when opening the edit endpoint modal and immediately starting
to edit a field, the field would revert to its initial value. This
doesn’t happen if the user waits a few seconds before starting to edit a
field.

This was caused by a concurrency issue between requests and fixed by no
longer making the requests if they are already in progress.
Sergiu Miclea il y a 4 ans
Parent
commit
c62a56eb41
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      src/stores/ProviderStore.ts

+ 7 - 0
src/stores/ProviderStore.ts

@@ -176,8 +176,15 @@ class ProviderStore {
     regionsField.enum = [...regionStore.regions]
   }
 
+  loadingForProvider: ProviderTypes | null = null
+
   @action async getConnectionInfoSchema(providerName: ProviderTypes): Promise<void> {
+    if (this.connectionSchemaLoading && this.loadingForProvider === providerName) {
+      return
+    }
+
     this.connectionSchemaLoading = true
+    this.loadingForProvider = providerName
 
     try {
       const fields: Field[] = await ProviderSource.getConnectionInfoSchema(providerName)