mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-21 12:12:45 +00:00
Terminal items were keyed by (System.currentTimeMillis(), System.nanoTime()). nanoTime() never goes backwards but is not unique: two items created within one clock tick get identical values, and currentTimeMillis() ties as well, so the whole key collides and LazyColumn throws "Key was already used". Terminal items are created on several threads - sendCmd runs in Dispatchers.IO, received events are processed in another coroutine, and rejected console commands on the main thread - and a command and its response are created back to back, so ties happen, more often with a coarse clock. Key by a per-item sequence number instead.