File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
app/src/main/java/com/duckduckgo/app/browser
duckchat-api/src/main/java/com/duckduckgo/duckchat/api
duckchat-impl/src/main/java/com/duckduckgo/duckchat/impl Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -4470,7 +4470,8 @@ class BrowserTabViewModel @Inject constructor(
44704470 val params = duckChat.createWasUsedBeforePixelParams()
44714471 pixel.fire(DuckChatPixelName .DUCK_CHAT_OPEN_BROWSER_MENU , parameters = params)
44724472 }
4473- duckChat.openDuckChat()
4473+ val url = duckChat.getDuckChatUrl(" " , false )
4474+ onUserSubmittedQuery(url)
44744475 }
44754476
44764477 fun onDuckChatOmnibarButtonClicked (
@@ -4481,11 +4482,14 @@ class BrowserTabViewModel @Inject constructor(
44814482 viewModelScope.launch {
44824483 command.value = HideKeyboardForChat
44834484 }
4484- when {
4485- hasFocus && isNtp && query.isNullOrBlank() -> duckChat.openDuckChat()
4486- hasFocus -> duckChat.openDuckChatWithAutoPrompt(query ? : " " )
4487- else -> duckChat.openDuckChat()
4485+
4486+ val url = when {
4487+ hasFocus && isNtp && query.isNullOrBlank() -> duckChat.getDuckChatUrl(query ? : " " , false )
4488+ hasFocus -> duckChat.getDuckChatUrl(query ? : " " , true )
4489+ else -> duckChat.getDuckChatUrl(query ? : " " , false )
44884490 }
4491+
4492+ onUserSubmittedQuery(url)
44894493 }
44904494
44914495 fun onVpnMenuClicked () {
Original file line number Diff line number Diff line change @@ -46,6 +46,11 @@ interface DuckChat {
4646 */
4747 fun openDuckChatWithPrefill (query : String )
4848
49+ /* *
50+ * Returns the Duck Chat URL to be used
51+ */
52+ fun getDuckChatUrl (query : String , autoPrompt : Boolean ): String
53+
4954 /* *
5055 * Determines whether a given [Uri] is a DuckChat URL.
5156 *
Original file line number Diff line number Diff line change @@ -481,6 +481,13 @@ class RealDuckChat @Inject constructor(
481481 openDuckChat(parameters, forceNewSession = true )
482482 }
483483
484+ override fun getDuckChatUrl (query : String , autoPrompt : Boolean ): String {
485+ logcat { " Duck.ai: getDuckChatUrl query $query autoPrompt $autoPrompt " }
486+ val parameters = addChatParameters(query, autoPrompt = autoPrompt)
487+ val url = appendParameters(parameters, duckChatLink)
488+ return url
489+ }
490+
484491 private fun addChatParameters (
485492 query : String ,
486493 autoPrompt : Boolean ,
You can’t perform that action at this time.
0 commit comments