fix: new messages not coming in when an edit comes in
Signed-off-by: Infi <wingit@geist.ga>
This commit is contained in:
parent
82c352191b
commit
1b9e458640
|
|
@ -10,6 +10,7 @@ import androidx.lifecycle.viewModelScope
|
||||||
import chat.revolt.api.RevoltAPI
|
import chat.revolt.api.RevoltAPI
|
||||||
import chat.revolt.api.RevoltJson
|
import chat.revolt.api.RevoltJson
|
||||||
import chat.revolt.api.internals.ULID
|
import chat.revolt.api.internals.ULID
|
||||||
|
import chat.revolt.api.realtime.RealtimeSocketFrames
|
||||||
import chat.revolt.api.realtime.frames.receivable.ChannelStartTypingFrame
|
import chat.revolt.api.realtime.frames.receivable.ChannelStartTypingFrame
|
||||||
import chat.revolt.api.realtime.frames.receivable.ChannelStopTypingFrame
|
import chat.revolt.api.realtime.frames.receivable.ChannelStopTypingFrame
|
||||||
import chat.revolt.api.realtime.frames.receivable.MessageDeleteFrame
|
import chat.revolt.api.realtime.frames.receivable.MessageDeleteFrame
|
||||||
|
|
@ -283,9 +284,12 @@ class ChannelScreenViewModel : ViewModel() {
|
||||||
currentMsg.id == it.id
|
currentMsg.id == it.id
|
||||||
} ?: return@onEach // Message not found, ignore.
|
} ?: return@onEach // Message not found, ignore.
|
||||||
|
|
||||||
|
if (messageFrame.author != null)
|
||||||
|
addUserIfUnknown(messageFrame.author)
|
||||||
|
|
||||||
regroupMessages(renderableMessages.map { currentMsg ->
|
regroupMessages(renderableMessages.map { currentMsg ->
|
||||||
if (currentMsg.id == it.id) {
|
if (currentMsg.id == it.id) {
|
||||||
messageFrame
|
currentMsg.mergeWithPartial(messageFrame)
|
||||||
} else {
|
} else {
|
||||||
currentMsg
|
currentMsg
|
||||||
}
|
}
|
||||||
|
|
@ -295,9 +299,10 @@ class ChannelScreenViewModel : ViewModel() {
|
||||||
is MessageDeleteFrame -> {
|
is MessageDeleteFrame -> {
|
||||||
if (it.channel != channel?.id) return@onEach
|
if (it.channel != channel?.id) return@onEach
|
||||||
|
|
||||||
regroupMessages(renderableMessages.filter { currentMsg ->
|
val newRenderableMessages = renderableMessages.filter { currentMsg ->
|
||||||
currentMsg.id != it.id
|
currentMsg.id != it.id
|
||||||
})
|
}
|
||||||
|
regroupMessages(newRenderableMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ChannelStartTypingFrame -> {
|
is ChannelStartTypingFrame -> {
|
||||||
|
|
@ -314,6 +319,11 @@ class ChannelScreenViewModel : ViewModel() {
|
||||||
|
|
||||||
_typingUsers.remove(it.user)
|
_typingUsers.remove(it.user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is RealtimeSocketFrames.Reconnected -> {
|
||||||
|
Log.d("ChannelScreen", "Reconnected to WS.")
|
||||||
|
listenForWsFrame()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.catch {
|
}.catch {
|
||||||
Log.e("ChannelScreen", "Failed to receive WS frame", it)
|
Log.e("ChannelScreen", "Failed to receive WS frame", it)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue