Skip to content

Commit

Permalink
Merge pull request #7879 from ikiw/master
Browse files Browse the repository at this point in the history
Resolve #7874 - stop too many fetch calls to docmanager-extension on …
  • Loading branch information
Steven Silvester committed Feb 15, 2020
2 parents 94949ba + 050d102 commit b66bb79
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 b66bb79

Please sign in to comment.