fix(#101): collect events once in init to prevent duplicate collectors on reconnect (#169)

This commit is contained in:
M57 authored and GitHub committed 2026-06-20 17:32:24 +03:00
1 parent 74714fc1df
commit 8763271056
2 files changed
+38 -6

No files matched your search

@@ -113,6 +113,11 @@ class ChatViewModel(
init {
connectWebSocket()
viewModelScope.launch {
wsClient.events.collect { event ->
handleWsEvent(event)
}
}
if (startCleanup) {
startPendingRequestCleanup()
}
@@ -128,12 +133,6 @@ class ChatViewModel(
viewModelScope.launch(Dispatchers.IO) {
wsClient.connect()
}
viewModelScope.launch {
wsClient.events.collect { event ->
handleWsEvent(event)
}
}
}
// ── WS Event Handling ────────────────────────────────────────────────