-
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?
Changes from 8 commits
6bd17fc
9d20d24
33862a3
0f63904
2910ecc
79fcdca
8760190
cc5528b
3114d36
6355e1b
81dac77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,6 @@ import com.duckduckgo.app.pixels.AppPixelName | |
import com.duckduckgo.app.statistics.pixels.Pixel | ||
import com.duckduckgo.app.statistics.pixels.Pixel.PixelParameter.FIRE_BUTTON_STATE | ||
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType.Unique | ||
import com.duckduckgo.app.tabs.model.TabEntity | ||
import com.duckduckgo.app.tabs.model.TabRepository | ||
import com.duckduckgo.app.trackerdetection.model.Entity | ||
import com.duckduckgo.browser.api.UserBrowserProperties | ||
|
@@ -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 commentThe 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 tabCount: Int = 0, | ||
val hasUnreadTabs: Boolean = false, | ||
val shouldUpdateTabsCount: Boolean = false, | ||
val showVoiceSearch: Boolean = false, | ||
val showClearButton: Boolean = false, | ||
|
@@ -126,13 +126,14 @@ class OmnibarLayoutViewModel @Inject constructor( | |
GLOBE, | ||
} | ||
|
||
fun onAttachedToWindow() { | ||
init { | ||
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 commentThe 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. |
||
tabCount = tabs.size, | ||
hasUnreadTabs = tabs.firstOrNull { !it.viewed } != null, | ||
) | ||
} | ||
}.flowOn(dispatcherProvider.io()) | ||
|
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.