Skip to content

Commit 0774a7d

Browse files
committed
fix(VoicePresenter): Hide "try again" when has partialResults
1 parent 96d2478 commit 0774a7d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ui/src/main/kotlin/com/algolia/instantsearch/voice/ui/VoicePresenter.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ class VoicePresenter(
1616
onResults(results.resultsRecognition)
1717
}
1818

19+
private var hasPartialResults: Boolean = false
20+
1921
override fun onPartialResults(partialResults: Bundle) {
2022
val matches = partialResults.resultsRecognition
2123

2224
ui.setSuggestionVisibility(false)
2325
ui.setTitle(VoiceUI.Title.Listen)
2426
matches.firstOrNull()?.capitalize()?.let(ui::setSubtitle)
27+
hasPartialResults = true
2528
}
2629

2730
override fun isListening(isListening: Boolean) {
@@ -33,7 +36,9 @@ class VoicePresenter(
3336
ui.setSubtitle(VoiceUI.Subtitle.Listen)
3437
ui.setMicrophoneState(VoiceMicrophone.State.Activated)
3538
} else {
36-
ui.setHintVisibility(true)
39+
if (!hasPartialResults) {
40+
ui.setHintVisibility(true)
41+
}
3742
ui.setRippleActivity(false)
3843
ui.setMicrophoneState(VoiceMicrophone.State.Deactivated)
3944
}
@@ -46,6 +51,7 @@ class VoicePresenter(
4651
ui.setMicrophoneState(VoiceMicrophone.State.Deactivated)
4752
ui.setTitle(VoiceUI.Title.Error)
4853
ui.setSubtitle(VoiceUI.Subtitle.Error)
54+
hasPartialResults = false
4955
}
5056

5157
override fun onReadyForSpeech(params: Bundle) = Unit

0 commit comments

Comments
 (0)