mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-13 03:01:05 +00:00
fix order of queued messages
add delay between sending of queued messages to increase the chance they are received on server in the correct order. This is not the best solution though as it blocks the UI a bit so may have to be improved! Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
569be55395
commit
dc32a4a2f1
@ -29,6 +29,7 @@ import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import java.lang.Thread.sleep
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessageInputViewModel @Inject constructor(
|
||||
@ -79,9 +80,6 @@ class MessageInputViewModel @Inject constructor(
|
||||
mediaPlayerManager.handleOnStop()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = MessageInputViewModel::class.java.simpleName
|
||||
}
|
||||
val getAudioFocusChange: LiveData<AudioFocusRequestManager.ManagerState>
|
||||
get() = audioFocusRequestManager.getManagerState
|
||||
|
||||
@ -252,6 +250,7 @@ class MessageInputViewModel @Inject constructor(
|
||||
dataStore.saveMessageQueue(roomToken, null) // empties the queue
|
||||
while (queue.size > 0) {
|
||||
val msg = queue.removeFirst()
|
||||
sleep(DELAY_BETWEEN_QUEUED_MESSAGES)
|
||||
sendChatMessage(
|
||||
roomToken,
|
||||
credentials,
|
||||
@ -272,4 +271,9 @@ class MessageInputViewModel @Inject constructor(
|
||||
messageQueue = dataStore.getMessageQueue(roomToken)
|
||||
_messageQueueSizeFlow.tryEmit(messageQueue.size)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = MessageInputViewModel::class.java.simpleName
|
||||
private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 100
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user