fix: prevent channel wipe on WS reconnect race condition
When the WS connects (including first connection), pushReconnectEvent() triggers loadMessages(50, ignoreExisting=true). If the initial load already fetched the same messages, ignoreExisting filters them all out, producing an empty list that updateItems() uses to clear the channel. Skip the update entirely when ignoreExisting yields no new messages. Signed-off-by: sanasol <mail@sanasol.ws>
This commit is contained in:
parent
dda158a848
commit
bfcec338c8
|
|
@ -535,6 +535,13 @@ class ChannelScreenViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
// Skip update if ignoreExisting filtered out all messages (e.g. WS reconnect
|
||||
// fetched the same messages already loaded) — otherwise updateItems([]) wipes the list
|
||||
if (ignoreExisting && newItems.isEmpty()) {
|
||||
if (!didInitialChannelFetch) didInitialChannelFetch = true
|
||||
return@launch
|
||||
}
|
||||
|
||||
// Place items according to whether above/below/around was specified.
|
||||
// TODO: Aditionally, place LoadTriggers at the beginning and end of the list.
|
||||
val newItemsWithPosition = when {
|
||||
|
|
|
|||
Loading…
Reference in New Issue