refactor _refreshExtensionPrimitives for clarity

The previous form made it harder to see that at most one extension
category is handled per call.
This commit is contained in:
Christopher Willis-Ford 2019-06-18 15:04:37 -07:00
parent edd6aafed0
commit fd776025e5

View file

@ -825,15 +825,14 @@ class Runtime extends EventEmitter {
* @private
*/
_refreshExtensionPrimitives (extensionInfo) {
for (const categoryInfo of this._blockInfo) {
if (extensionInfo.id === categoryInfo.id) {
categoryInfo.name = maybeFormatMessage(extensionInfo.name);
categoryInfo.blocks = [];
categoryInfo.menus = [];
this._fillExtensionCategory(categoryInfo, extensionInfo);
const categoryInfo = this._blockInfo.find(info => info.id === extensionInfo.id);
if (categoryInfo) {
categoryInfo.name = maybeFormatMessage(extensionInfo.name);
categoryInfo.blocks = [];
categoryInfo.menus = [];
this._fillExtensionCategory(categoryInfo, extensionInfo);
this.emit(Runtime.BLOCKSINFO_UPDATE, categoryInfo);
}
this.emit(Runtime.BLOCKSINFO_UPDATE, categoryInfo);
}
}