mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 14:24:05 +01:00
pass newestMessageIdFromDb to initMessagePolling
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
7eb8b9fa70
commit
c81b1fa62f
@ -56,10 +56,8 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
||||
* Long polls the server for any updates to the chat, if found, it synchronizes
|
||||
* the database with the server and emits the new messages to [messageFlow],
|
||||
* else it simply retries after timeout.
|
||||
*
|
||||
* [withNetworkParams] credentials and url.
|
||||
*/
|
||||
fun initMessagePolling(): Job
|
||||
fun initMessagePolling(initialMessageId: Long): Job
|
||||
|
||||
/**
|
||||
* Gets a individual message.
|
||||
|
@ -158,6 +158,8 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
Log.d(TAG, "newestMessageId after sync: $newestMessageIdFromDb")
|
||||
} else {
|
||||
Log.d(TAG, "Initial online request is skipped because offline messages are up to date")
|
||||
// if conversationModel was not up to date and there are new messages, they will just get pulled with
|
||||
// look into future.. Old messages will be displayed immediately beforehand.
|
||||
}
|
||||
|
||||
val limit = getCappedMessagesAmountOfChatBlock(newestMessageIdFromDb)
|
||||
@ -175,7 +177,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
updateUiForLastCommonRead()
|
||||
updateUiForLastReadMessage(newestMessageIdFromDb)
|
||||
|
||||
initMessagePolling()
|
||||
initMessagePolling(newestMessageIdFromDb)
|
||||
}
|
||||
|
||||
private suspend fun getCappedMessagesAmountOfChatBlock(messageId: Long): Int {
|
||||
@ -240,18 +242,17 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
updateUiForLastCommonRead()
|
||||
}
|
||||
|
||||
override fun initMessagePolling(): Job =
|
||||
override fun initMessagePolling(initialMessageId: Long): Job =
|
||||
scope.launch {
|
||||
Log.d(TAG, "---- initMessagePolling ------------")
|
||||
|
||||
val initialMessageId = chatDao.getNewestMessageId(internalConversationId).toInt()
|
||||
Log.d(TAG, "newestMessage: $initialMessageId")
|
||||
|
||||
var fieldMap = getFieldMap(
|
||||
lookIntoFuture = true,
|
||||
includeLastKnown = false,
|
||||
setReadMarker = true,
|
||||
lastKnown = initialMessageId
|
||||
lastKnown = initialMessageId.toInt()
|
||||
)
|
||||
|
||||
val networkParams = Bundle()
|
||||
|
Loading…
Reference in New Issue
Block a user