Skip to content

Commit

Permalink
For issue mozilla-mobile#12126 - Tab counter consumeFrom update
Browse files Browse the repository at this point in the history
Added a direct call to the updateTabCounter method to account for changes made to the BrowserState while the tabCounter view is not visible.
  • Loading branch information
Mihai Eduard Badea committed Jul 7, 2020
1 parent 388c144 commit e23b951
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.state.selector.normalTabs
import mozilla.components.browser.state.selector.privateTabs
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount
Expand Down Expand Up @@ -390,15 +391,9 @@ class HomeFragment : Fragment() {
}

consumeFrom(requireComponents.core.store) {
val tabCount = if (browsingModeManager.mode.isPrivate) {
it.privateTabs.size
} else {
it.normalTabs.size
}

view.tab_button?.setCountWithAnimation(tabCount)
view.add_tabs_to_collections_button?.isVisible = tabCount > 0
updateTabCounter(it)
}
updateTabCounter(requireComponents.core.store.state)
}

override fun onDestroyView() {
Expand Down Expand Up @@ -935,6 +930,17 @@ class HomeFragment : Fragment() {
TabTrayDialogFragment.show(parentFragmentManager)
}

private fun updateTabCounter(browserState: BrowserState){
val tabCount = if (browsingModeManager.mode.isPrivate) {
browserState.privateTabs.size
} else {
browserState.normalTabs.size
}

view?.tab_button?.setCountWithAnimation(tabCount)
view?.add_tabs_to_collections_button?.isVisible = tabCount > 0
}

companion object {
private const val ANIMATION_DELAY = 100L

Expand Down

0 comments on commit e23b951

Please sign in to comment.