fix: keep typing indicator in sync with realtime messages
fix: clear typing state when message arrives and ignore self typing events
This commit is contained in:
@@ -826,6 +826,7 @@ class ChatViewModel @Inject constructor(
|
|||||||
when (event) {
|
when (event) {
|
||||||
is RealtimeEvent.TypingStart -> {
|
is RealtimeEvent.TypingStart -> {
|
||||||
if (event.chatId != chatId) return@collectLatest
|
if (event.chatId != chatId) return@collectLatest
|
||||||
|
if (event.userId != null && event.userId == uiState.value.selfUserId) return@collectLatest
|
||||||
typingResetJob?.cancel()
|
typingResetJob?.cancel()
|
||||||
_uiState.update {
|
_uiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
@@ -867,6 +868,21 @@ class ChatViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is RealtimeEvent.ReceiveMessage -> {
|
||||||
|
if (event.chatId != chatId) return@collectLatest
|
||||||
|
typingResetJob?.cancel()
|
||||||
|
_uiState.update {
|
||||||
|
it.copy(
|
||||||
|
isTyping = false,
|
||||||
|
chatSubtitle = resolveDisplayedSubtitle(
|
||||||
|
baseSubtitle = it.baseChatSubtitle,
|
||||||
|
isRealtimeConnecting = it.isRealtimeConnecting,
|
||||||
|
isTyping = false,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user