Skip to content

Commit

Permalink
For mozilla-mobile#27975: Ignore current tab when forcing inactive
Browse files Browse the repository at this point in the history
Since the crash was caused by having the current tab set as inactive
while the user was still able to see it, now we ignore the current
tab if it is selected to be set as inactive.
  • Loading branch information
DreVla committed Jan 13, 2023
1 parent 322fe9c commit 36bde2a
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,16 @@ class DefaultTabsTrayController(
*/
@OptIn(DelicateAction::class)
override fun forceTabsAsInactive(tabs: Collection<TabSessionState>, numOfDays: Long) {
tabs.forEach { tab ->
val daysSince = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(numOfDays)
browserStore.apply {
dispatch(LastAccessAction.UpdateLastAccessAction(tab.id, daysSince))
dispatch(DebugAction.UpdateCreatedAtAction(tab.id, daysSince))
val currentTabId = browserStore.state.selectedTabId
tabs
.filterNot { it.id == currentTabId }
.forEach { tab ->
val daysSince = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(numOfDays)
browserStore.apply {
dispatch(LastAccessAction.UpdateLastAccessAction(tab.id, daysSince))
dispatch(DebugAction.UpdateCreatedAtAction(tab.id, daysSince))
}
}
}
}

@VisibleForTesting
Expand Down

0 comments on commit 36bde2a

Please sign in to comment.