fix: Don't show "Remove tab" menu if there are no tabs (#1179)

Prevents a crash that would otherwise occur.
This commit is contained in:
Nik Clayton 2024-12-13 15:18:01 +01:00 committed by GitHub
parent a66da06c2c
commit ed77d7aeb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -482,7 +482,9 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
override fun onPrepareMenu(menu: Menu) {
super<BottomSheetActivity>.onPrepareMenu(menu)
menu.findItem(R.id.action_remove_tab).isVisible = tabAdapter.tabs.getOrNull(binding.viewPager.currentItem)?.timeline != Timeline.Home
menu.findItem(R.id.action_remove_tab).isVisible = tabAdapter.tabs.getOrNull(binding.viewPager.currentItem)?.let {
it.timeline != Timeline.Home
} ?: false
// If the main toolbar is hidden then there's no space in the top/bottomNav to show
// the menu items as icons, so forceably disable them