mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-04 02:25:04 +01:00
only delay readStatus handling for initial loading
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
0390c93ed2
commit
b757164c6d
@ -123,18 +123,19 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
internalConversationId,
|
internalConversationId,
|
||||||
chatDao.getNewestMessageId(internalConversationId)
|
chatDao.getNewestMessageId(internalConversationId)
|
||||||
)
|
)
|
||||||
updateUiForLastCommonRead()
|
updateUiForLastCommonRead(200)
|
||||||
|
|
||||||
initMessagePolling()
|
initMessagePolling()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUiForLastCommonRead(){
|
private fun updateUiForLastCommonRead(delay: Long) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// TODO improve...
|
|
||||||
// delay is a dirty workaround to make sure messages are added to adapter on initial load before setting
|
// delay is a dirty workaround to make sure messages are added to adapter on initial load before setting
|
||||||
// their read status.
|
// their read status(otherwise there is a race condition between adding messages and setting their read
|
||||||
// This workaround causes that the checkmarks seem to switch whenever sending a message
|
// status).
|
||||||
delay(200)
|
if (delay > 0) {
|
||||||
|
delay(delay)
|
||||||
|
}
|
||||||
newXChatLastCommonRead?.let {
|
newXChatLastCommonRead?.let {
|
||||||
_lastCommonReadFlow.emit(it)
|
_lastCommonReadFlow.emit(it)
|
||||||
}
|
}
|
||||||
@ -165,7 +166,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
showLast100MessagesBefore(internalConversationId, beforeMessageId)
|
showLast100MessagesBefore(internalConversationId, beforeMessageId)
|
||||||
updateUiForLastCommonRead()
|
updateUiForLastCommonRead(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initMessagePolling(): Job =
|
override fun initMessagePolling(): Job =
|
||||||
@ -199,7 +200,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
_messageFlow.emit(pair)
|
_messageFlow.emit(pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUiForLastCommonRead()
|
updateUiForLastCommonRead(0)
|
||||||
|
|
||||||
// Process read status if not null
|
// Process read status if not null
|
||||||
// val lastKnown = datastore.getLastKnownId(internalConversationId, 0)
|
// val lastKnown = datastore.getLastKnownId(internalConversationId, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user