Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #7874 - stop too many fetch calls to docmanager-extension on … #7879

Merged
merged 2 commits into from Feb 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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