-
Notifications
You must be signed in to change notification settings - Fork 929
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
@@ -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.
val viewState = _viewState.asStateFlow() | ||
val viewState = combine(_viewState, tabRepository.flowTabs) { state, tabs -> | ||
state.copy( | ||
shouldUpdateTabsCount = tabs.size != state.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.
…iping-animation-fix # Conflicts: # app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt # app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayout.kt
…iping-animation-fix # Conflicts: # app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayout.kt
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