Avoid calling expensive ActionsMenuItemsRegistry.getItems

Change-Id: I6ba87ea91d1aca151882f96f4e164b07064bf040
This commit is contained in:
thiemowmde
2024-04-04 10:13:51 +02:00
committed by jenkins-bot
parent 411aabe32e
commit b086aebcc8

View File

@@ -87,9 +87,7 @@
$emptyStateContainer.append( $header, $desc );
uls.$resultsView.append( $emptyStateContainer );
var actionItems = actionItemsRegistry.getItems();
if ( actionItems.length > 1 ) {
if ( actionItemsRegistry.size() > 1 ) {
// languageSettingsMenuItem will be always there.
// If other actions available, change text
$header.text( $.i18n( 'ext-uls-empty-state-header-actions-available' ) );
@@ -99,7 +97,7 @@
// Action menu items need OOUI widgets. Load them and register trigger event handler.
mw.loader.using( [ 'oojs-ui-widgets', 'oojs-ui.styles.icons-interactions' ] ).done( function () {
var $actionsList = $( '<ul>' ).addClass( 'uls-language-action-items' );
actionItems.forEach( function ( actionItem ) {
actionItemsRegistry.getItems().forEach( function ( actionItem ) {
var actionButton = new ActionsMenuItem(
actionItem.icon,
actionItem.text,
@@ -111,7 +109,6 @@
$emptyStateContainer.append( $actionsList );
} );
}
/**
@@ -185,7 +182,7 @@
} );
};
if ( actionItemsRegistry.getItems().length ) {
if ( actionItemsRegistry.size() ) {
prependAddLanguagesMenuButton();
}
function onActionItemAdded( itemName, item ) {