Skip to content

Commit

Permalink
Allow refreshBlocks() to specify extension (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
FurryR authored Dec 26, 2024
1 parent b900a37 commit 56825e3
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/extension-support/extension-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,25 @@ class ExtensionManager {

/**
* Regenerate blockinfo for any loaded extensions
* @param {string} [optExtensionId] Optional extension ID for refreshing
* @returns {Promise} resolved once all the extensions have been reinitialized
*/
refreshBlocks () {
const allPromises = Array.from(this._loadedExtensions.values()).map(serviceName =>
dispatch.call(serviceName, 'getInfo')
.then(info => {
info = this._prepareExtensionInfo(serviceName, info);
dispatch.call('runtime', '_refreshExtensionPrimitives', info);
})
.catch(e => {
log.error('Failed to refresh built-in extension primitives', e);
})
);
refreshBlocks (optExtensionId) {
const refresh = serviceName => dispatch.call(serviceName, 'getInfo')
.then(info => {
info = this._prepareExtensionInfo(serviceName, info);
dispatch.call('runtime', '_refreshExtensionPrimitives', info);
})
.catch(e => {
log.error('Failed to refresh built-in extension primitives', e);
});
if (optExtensionId) {
if (!this._loadedExtensions.has(optExtensionId)) {
return Promise.reject(new Error(`Unknown extension: ${optExtensionId}`));
}
return refresh(this._loadedExtensions.get(optExtensionId));
}
const allPromises = Array.from(this._loadedExtensions.values()).map(refresh);
return Promise.all(allPromises);
}

Expand Down

0 comments on commit 56825e3

Please sign in to comment.