Skip to content

Commit

Permalink
Resolve #7874 - stop too many fetch calls to docmanager-extension on …
Browse files Browse the repository at this point in the history
…first load
  • Loading branch information
selango committed Feb 13, 2020
1 parent 7a97756 commit c74b22c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/docmanager-extension/src/index.ts
Expand Up @@ -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;
}
Expand Down

0 comments on commit c74b22c

Please sign in to comment.