mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 12:17:22 +00:00
Prevent search state from clearing if user did not send a message.
This commit is contained in:
committed by
Cody Henthorne
parent
d6eb675fd0
commit
3aefd3bdc6
@@ -141,7 +141,7 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f
|
||||
}
|
||||
|
||||
private fun presentToolbarForConversationListFragment() {
|
||||
toolbarViewModel.setToolbarMode(MainToolbarMode.FULL, destination = MainNavigationListLocation.CHATS)
|
||||
toolbarViewModel.setToolbarMode(MainToolbarMode.FULL, destination = MainNavigationListLocation.CHATS, overwriteSearchMode = false)
|
||||
}
|
||||
|
||||
private fun presentToolbarForConversationListArchiveFragment() {
|
||||
|
||||
@@ -74,14 +74,29 @@ class MainToolbarViewModel : ViewModel() {
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun setToolbarMode(mode: MainToolbarMode, destination: MainNavigationListLocation? = null) {
|
||||
fun setToolbarMode(
|
||||
mode: MainToolbarMode,
|
||||
destination: MainNavigationListLocation? = null,
|
||||
overwriteSearchMode: Boolean = true
|
||||
) {
|
||||
val previousMode = internalStateFlow.value.mode
|
||||
|
||||
internalStateFlow.update {
|
||||
it.copy(mode = mode, destination = destination ?: it.destination, searchQuery = "")
|
||||
val newMode = if (previousMode == MainToolbarMode.SEARCH && !overwriteSearchMode) {
|
||||
previousMode
|
||||
} else {
|
||||
mode
|
||||
}
|
||||
|
||||
emitPossibleSearchStateChangeEvent(previousMode, mode)
|
||||
val newSearchQuery = if (previousMode == MainToolbarMode.SEARCH && !overwriteSearchMode) {
|
||||
internalStateFlow.value.searchQuery
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
internalStateFlow.update {
|
||||
it.copy(mode = newMode, destination = destination ?: it.destination, searchQuery = newSearchQuery)
|
||||
}
|
||||
|
||||
emitPossibleSearchStateChangeEvent(previousMode, newMode)
|
||||
}
|
||||
|
||||
fun setProxyState(proxyState: MainToolbarState.ProxyState) {
|
||||
|
||||
Reference in New Issue
Block a user