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 committed 2019-06-18 15:08:03 -07:00
1 parent edd6aafed0
commit fd776025e5
1 file changed
+7 -8
+7 -8
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);
}
}