Skip to content

Commit 3cae589

Browse files
committed
Fix tab swap logic to account for total tab switcher items
1 parent 710f2e7 commit 3cae589

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/main/java/com/duckduckgo/app/tabs/ui/TabSwitcherActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,9 @@ class TabSwitcherActivity : DuckDuckGoActivity(), TabSwitcherListener, Coroutine
434434
if (tabSwitcherAnimationFeature.self().isEnabled()) {
435435
val isTrackerAnimationTileVisible = viewModel.tabSwitcherItems.value?.get(0) is TabSwitcherItem.TrackerAnimationTile
436436
val canSwapFromIndex = if (isTrackerAnimationTileVisible) 1 else 0
437-
val tabItemCount = viewModel.tabSwitcherItems.value?.count { it is TabSwitcherItem.Tab } ?: 0
437+
val tabSwitcherItemCount = viewModel.tabSwitcherItems.value?.count() ?: 0
438438

439-
val canSwap = from in canSwapFromIndex..<tabItemCount && to in canSwapFromIndex..<tabItemCount
439+
val canSwap = from in canSwapFromIndex..<tabSwitcherItemCount && to in canSwapFromIndex..<tabSwitcherItemCount
440440
if (canSwap) {
441441
tabsAdapter.onTabMoved(from, to)
442442
// Adjust indices if animation feature is enabled to account for the TrackerAnimationTile at index 0

0 commit comments

Comments
 (0)