Browse Source

Resolve #7874 - stop too many fetch calls to docmanager-extension on first load

selango 5 năm trước cách đây
mục cha
commit
c74b22c304
1 tập tin đã thay đổi với 15 bổ sung1 xóa
  1. 15 1
      packages/docmanager-extension/src/index.ts

+ 15 - 1
packages/docmanager-extension/src/index.ts

@@ -241,9 +241,23 @@ ${fileTypes}`;
         return { ...plugin, schema };
       }
     });
+
+    //callback to registry change that ensures not to invoke reload method when there is already a promise that is pending
+    let reloadSettingsRegistry = () => {
+      let promisePending = false;
+
+      return async () => {
+          if(!promisePending) {
+            promisePending = true;
+            await settingRegistry.reload(pluginId);
+            promisePending = false;
+          }
+      };
+    };
+
     // If the document registry gains or loses a factory or file type,
     // regenerate the settings description with the available options.
-    registry.changed.connect(() => settingRegistry.reload(pluginId));
+    registry.changed.connect(reloadSettingsRegistry());
 
     return docManager;
   }