Skip to content

Commit 988bf8d

Browse files
Fixed navigateToGemini check
1 parent 134274a commit 988bf8d

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

composeApp/src/commonMain/kotlin/ui/screen/GeminiTab.kt

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ fun GeminiScreenView(navigator: Navigator, viewModel: HomeScreenModel){
115115
val navigateToGemini by viewModel.navigateToGemini.collectAsState()
116116
var prompt by remember { mutableStateOf("") }
117117
val canClearPrompt by remember { derivedStateOf { prompt.isNotBlank() } }
118-
if (navigateToGemini.second != null) {
119-
prompt = """
118+
if (navigateToGemini.first && navigateToGemini.second != null) {
119+
val customPrompt = """
120120
As a tourist, I want to explore and learn about a destination. Please provide comprehensive information about the following place: ${navigateToGemini.second?.title}.
121121
Include key details such as:
122122
- A brief overview of the place
@@ -128,22 +128,20 @@ fun GeminiScreenView(navigator: Navigator, viewModel: HomeScreenModel){
128128
- Navigation routes or how to reach there from common locations
129129
Make the information engaging and easy to understand.
130130
""".trimIndent()
131-
if (prompt.isNotBlank()) {
132-
coroutineScope.launch {
133-
println("prompt = $prompt")
134-
content = ""
135-
generateContentAsFlow(api, prompt, selectedImageData)
136-
.onStart { showProgress = true }
137-
.onCompletion {
138-
showProgress = false
139-
viewModel.navigateToGimini(Pair(false, null))
140-
}
141-
.collect {
142-
showProgress = false
143-
println("response = ${it.text}")
144-
content += it.text
145-
}
146-
}
131+
coroutineScope.launch {
132+
println("prompt = $customPrompt")
133+
content = ""
134+
generateContentAsFlow(api, customPrompt, selectedImageData)
135+
.onStart { showProgress = true }
136+
.onCompletion {
137+
showProgress = false
138+
viewModel.navigateToGimini(navigateToGemini.copy(false))
139+
}
140+
.collect {
141+
showProgress = false
142+
println("response = ${it.text}")
143+
content += it.text
144+
}
147145
}
148146
}
149147

0 commit comments

Comments
 (0)