Skip to content

Commit bdc0222

Browse files
committed
fix tab lifecycle for input screen
1 parent 41fbe35 commit bdc0222

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/inputscreen/ui/state/InputScreenVisibilityState.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
package com.duckduckgo.duckchat.impl.inputscreen.ui.state
1818

1919
data class InputScreenVisibilityState(
20-
val submitButtonVisible: Boolean,
21-
val voiceInputButtonVisible: Boolean,
22-
val autoCompleteSuggestionsVisible: Boolean,
23-
val bottomFadeVisible: Boolean,
24-
val showChatLogo: Boolean,
25-
val showSearchLogo: Boolean,
26-
val newLineButtonVisible: Boolean,
27-
val mainButtonsVisible: Boolean,
28-
val searchMode: Boolean,
20+
val submitButtonVisible: Boolean = false,
21+
val voiceInputButtonVisible: Boolean = false,
22+
val autoCompleteSuggestionsVisible: Boolean = false,
23+
val bottomFadeVisible: Boolean = false,
24+
val showChatLogo: Boolean = true,
25+
val showSearchLogo: Boolean = true,
26+
val newLineButtonVisible: Boolean = false,
27+
val mainButtonsVisible: Boolean = false,
28+
val searchMode: Boolean = false,
29+
val fullScreenMode: Boolean = false,
2930
) {
3031
val actionButtonsContainerVisible: Boolean = submitButtonVisible || voiceInputButtonVisible || newLineButtonVisible
3132
}

duckchat/duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl/inputscreen/ui/viewmodel/InputScreenViewModel.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import com.duckduckgo.browser.api.autocomplete.AutoCompleteSettings
4141
import com.duckduckgo.common.utils.DispatcherProvider
4242
import com.duckduckgo.common.utils.SingleLiveEvent
4343
import com.duckduckgo.common.utils.extensions.toBinaryString
44+
import com.duckduckgo.duckchat.api.DuckAiFeatureState
4445
import com.duckduckgo.duckchat.api.DuckChat
4546
import com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenConfigResolver
4647
import com.duckduckgo.duckchat.impl.inputscreen.ui.command.Command
@@ -123,6 +124,7 @@ class InputScreenViewModel @AssistedInject constructor(
123124
private val voiceSearchAvailability: VoiceSearchAvailability,
124125
private val autoCompleteSettings: AutoCompleteSettings,
125126
private val duckChat: DuckChat,
127+
private val duckAiFeatureState: DuckAiFeatureState,
126128
private val pixel: Pixel,
127129
private val sessionStore: InputScreenSessionStore,
128130
private val inputScreenDiscoveryFunnel: InputScreenDiscoveryFunnel,
@@ -155,6 +157,7 @@ class InputScreenViewModel @AssistedInject constructor(
155157
newLineButtonVisible = false,
156158
mainButtonsVisible = false,
157159
searchMode = true,
160+
fullScreenMode = duckAiFeatureState.showFullScreenMode.value,
158161
),
159162
)
160163
val visibilityState: StateFlow<InputScreenVisibilityState> = _visibilityState.asStateFlow()
@@ -414,14 +417,19 @@ class InputScreenViewModel @AssistedInject constructor(
414417

415418
fun onChatSubmitted(query: String) {
416419
viewModelScope.launch {
417-
val wasDuckAiOpenedBefore = duckChat.wasOpenedBefore()
418-
if (isWebUrl(query)) {
419-
command.value = Command.SubmitSearch(query)
420-
} else {
421-
command.value = Command.SubmitChat(query)
422-
duckChat.openDuckChatWithAutoPrompt(query)
420+
when {
421+
_visibilityState.value.fullScreenMode -> {
422+
val url = duckChat.getDuckChatUrl(query, true)
423+
command.value = Command.SubmitSearch(url)
424+
}
425+
isWebUrl(query) -> command.value = Command.SubmitSearch(query)
426+
else -> {
427+
command.value = Command.SubmitChat(query)
428+
duckChat.openDuckChatWithAutoPrompt(query)
429+
}
423430
}
424431

432+
val wasDuckAiOpenedBefore = duckChat.wasOpenedBefore()
425433
val params =
426434
mapOf(
427435
DuckChatPixelParameters.WAS_USED_BEFORE to wasDuckAiOpenedBefore.toBinaryString(),

0 commit comments

Comments
 (0)