-
Notifications
You must be signed in to change notification settings - Fork 928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swiping tabs: Fix duplicate animations & edit mode detection #5481
base: feature/ondrej/swiping-tabs
Are you sure you want to change the base?
Swiping tabs: Fix duplicate animations & edit mode detection #5481
Conversation
tabRepository.flowTabs | ||
.onEach { tabs -> | ||
_viewState.update { | ||
it.copy( | ||
shouldUpdateTabsCount = tabs.count() != it.tabs.count() || tabs.isNotEmpty(), | ||
tabs = tabs, | ||
shouldUpdateTabsCount = tabs.size != it.tabCount && tabs.isNotEmpty(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the original condition was wrong — we don’t ever want to show 0 (the initial ViewState value), because the actual count will always be at least 1.
@@ -99,7 +98,8 @@ class OmnibarLayoutViewModel @Inject constructor( | |||
val updateOmnibarText: Boolean = false, | |||
val shouldMoveCaretToEnd: Boolean = false, | |||
val shouldMoveCaretToStart: Boolean = false, | |||
val tabs: List<TabEntity> = emptyList(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list was only used to count the tabs. Each tab would contain a list of all these entities and with lots of tabs this would unnecessarily take up a lot of memory.
@@ -238,24 +246,30 @@ class OmnibarLayout @JvmOverloads constructor( | |||
)[OmnibarLayoutViewModel::class.java] | |||
} | |||
|
|||
// One OmnibarLayout is always removed from the view hierarchy, we should cancel any flow subscriptions | |||
fun onRemoved() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either the bottom or the top omnibar is always removed but its ViewModel flow subscriptions would keep collecting & rendering state for no reason.
Task/Issue URL: https://app.asana.com/0/1207418217763355/1209152058231741/f
Description
This PR removes the onboarding restriction that prevents tab swiping until onboarding is complete. It also fixes a bug that shows duplicate omnibar highlight animations. The bug is caused due to RecyclerView calling the
View.onAttachedToWindow()
every time the current item is changed, resulting in duplicatePulseAnimation
instances.The fix involves removing
PulseAnimation
initialization from theonAttachedToWindow()
callback, so that it’s initialized only once.I also moved the injection to the constructor to avoid repeated injection calls and refactored the ViewModel flows collection to only happen during active lifecycle states.
While working on this, I discovered that edit mode wasn’t working properly and there’s a simpler way to do it, so I included it here.
Steps to test this PR