Avoid calling expensive ActionsMenuItemsRegistry.getItems
Change-Id: I6ba87ea91d1aca151882f96f4e164b07064bf040
This commit is contained in:
@@ -87,9 +87,7 @@
|
|||||||
$emptyStateContainer.append( $header, $desc );
|
$emptyStateContainer.append( $header, $desc );
|
||||||
uls.$resultsView.append( $emptyStateContainer );
|
uls.$resultsView.append( $emptyStateContainer );
|
||||||
|
|
||||||
var actionItems = actionItemsRegistry.getItems();
|
if ( actionItemsRegistry.size() > 1 ) {
|
||||||
|
|
||||||
if ( actionItems.length > 1 ) {
|
|
||||||
// languageSettingsMenuItem will be always there.
|
// languageSettingsMenuItem will be always there.
|
||||||
// If other actions available, change text
|
// If other actions available, change text
|
||||||
$header.text( $.i18n( 'ext-uls-empty-state-header-actions-available' ) );
|
$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.
|
// 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 () {
|
mw.loader.using( [ 'oojs-ui-widgets', 'oojs-ui.styles.icons-interactions' ] ).done( function () {
|
||||||
var $actionsList = $( '<ul>' ).addClass( 'uls-language-action-items' );
|
var $actionsList = $( '<ul>' ).addClass( 'uls-language-action-items' );
|
||||||
actionItems.forEach( function ( actionItem ) {
|
actionItemsRegistry.getItems().forEach( function ( actionItem ) {
|
||||||
var actionButton = new ActionsMenuItem(
|
var actionButton = new ActionsMenuItem(
|
||||||
actionItem.icon,
|
actionItem.icon,
|
||||||
actionItem.text,
|
actionItem.text,
|
||||||
@@ -111,7 +109,6 @@
|
|||||||
|
|
||||||
$emptyStateContainer.append( $actionsList );
|
$emptyStateContainer.append( $actionsList );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,7 +182,7 @@
|
|||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( actionItemsRegistry.getItems().length ) {
|
if ( actionItemsRegistry.size() ) {
|
||||||
prependAddLanguagesMenuButton();
|
prependAddLanguagesMenuButton();
|
||||||
}
|
}
|
||||||
function onActionItemAdded( itemName, item ) {
|
function onActionItemAdded( itemName, item ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user