Skip to content

Commit 459332a

Browse files
committed
Add check for "isLoading" before update UI with "Typing..." animation
1 parent e312930 commit 459332a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sample/android/src/main/java/co/yml/ychat/android/MainViewModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ class MainViewModel(private val chatGpt: YChat) : ViewModel() {
5858
}
5959

6060
fun updateTyping(string: String) {
61-
typingTxt.value = if (typingTxt.value.endsWith("...")) string else "${typingTxt.value}."
62-
items[items.lastIndex] = items.last().copy(message = typingTxt.value)
61+
if (_isLoading.value == true) {
62+
typingTxt.value = if (typingTxt.value.endsWith("...")) string else "${typingTxt.value}."
63+
items[items.lastIndex] = items.last().copy(message = typingTxt.value)
64+
}
6365
}
6466

6567
private fun updateTypingMessage(typingStr: String) {

0 commit comments

Comments
 (0)