diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/utils/ReaderTopBarMenuHelper.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/utils/ReaderTopBarMenuHelper.kt index 33a33e476e69..e5b979bd9bc3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/utils/ReaderTopBarMenuHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/utils/ReaderTopBarMenuHelper.kt @@ -55,24 +55,30 @@ class ReaderTopBarMenuHelper @Inject constructor( .takeIf { it.isNotEmpty() } ?.let { customListsArray -> add(MenuElementData.Divider) - if (customListsArray.size() > 2) { - // If custom lists has more than 2 items, we add a submenu called "Lists" - add(createCustomListsItem(customListsArray)) - } else { - // If the custom lists has 2 or less items, we add the items directly without submenu - customListsArray.forEach { index, readerTag -> - add( - MenuElementData.Item.Single( - id = getMenuItemIdFromReaderTagIndex(index), - text = UiString.UiStringText(readerTag.tagTitle), - ) - ) - } - } + createCustomListsItems(customListsArray) } } } + private fun MutableList.createCustomListsItems( + customListsArray: SparseArrayCompat + ) { + if (customListsArray.size() > 2) { + // If custom lists has more than 2 items, we add a submenu called "Lists" + add(createCustomListsItem(customListsArray)) + } else { + // If the custom lists has 2 or less items, we add the items directly without submenu + customListsArray.forEach { index, readerTag -> + add( + MenuElementData.Item.Single( + id = getMenuItemIdFromReaderTagIndex(index), + text = UiString.UiStringText(readerTag.tagTitle), + ) + ) + } + } + } + private fun createDiscoverItem(id: String): MenuElementData.Item.Single { return MenuElementData.Item.Single( id = id,