From ab391ec475a8d8ed9f5c835df0464ce93da62deb Mon Sep 17 00:00:00 2001 From: benya Date: Sun, 5 Apr 2026 14:57:55 +0300 Subject: [PATCH] fix: keep typing indicator in sync with realtime messages fix: clear typing state when message arrives and ignore self typing events --- .../messenger/ui/chat/ChatViewModel.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt index ebd806c..4129dce 100644 --- a/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt +++ b/android/app/src/main/java/ru/daemonlord/messenger/ui/chat/ChatViewModel.kt @@ -826,6 +826,7 @@ class ChatViewModel @Inject constructor( when (event) { is RealtimeEvent.TypingStart -> { if (event.chatId != chatId) return@collectLatest + if (event.userId != null && event.userId == uiState.value.selfUserId) return@collectLatest typingResetJob?.cancel() _uiState.update { 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 } }