mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
fixed deletion bug, implemented Marcel's suggestions
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
2a4910e194
commit
250dbe37e3
3 changed files with 8 additions and 5 deletions
|
@ -178,12 +178,12 @@ class MessageInputFragment : Fragment() {
|
|||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
var wasOnline = true
|
||||
networkMonitor.isOnline.onEach { isOnline ->
|
||||
var wasOnline: Boolean // TODO maye redo this logic, seems it might be misfiring
|
||||
networkMonitor.isOnline
|
||||
.onEach { isOnline ->
|
||||
wasOnline = !binding.fragmentConnectionLost.isShown
|
||||
val connectionGained = (!wasOnline && isOnline)
|
||||
wasOnline = !binding.fragmentMessageInputView.isShown
|
||||
Log.d(TAG, "isOnline: $isOnline\nwasOnline: $wasOnline\nconnectionGained: $connectionGained")
|
||||
// delay(2000)
|
||||
handleMessageQueue(isOnline)
|
||||
handleUI(isOnline, connectionGained)
|
||||
}.collect()
|
||||
|
|
|
@ -142,6 +142,7 @@ class MessageInputViewModel @Inject constructor(
|
|||
if (isQueueing) {
|
||||
val tempID = System.currentTimeMillis().toInt()
|
||||
val qMsg = QueuedMessage(tempID, message, displayName, replyTo, sendWithoutNotification)
|
||||
messageQueue = dataStore.getMessageQueue(roomToken)
|
||||
messageQueue.add(qMsg)
|
||||
dataStore.saveMessageQueue(roomToken, messageQueue)
|
||||
_messageQueueSizeFlow.update { messageQueue.size }
|
||||
|
@ -257,7 +258,7 @@ class MessageInputViewModel @Inject constructor(
|
|||
val queue = dataStore.getMessageQueue(roomToken)
|
||||
dataStore.saveMessageQueue(roomToken, null) // empties the queue
|
||||
while (queue.size > 0) {
|
||||
val msg = queue.removeFirst()
|
||||
val msg = queue.removeAt(0)
|
||||
sendChatMessage(
|
||||
roomToken,
|
||||
credentials,
|
||||
|
|
|
@ -20,6 +20,7 @@ import kotlinx.coroutines.channels.awaitClose
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -73,6 +74,7 @@ class NetworkMonitorImpl @Inject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.flowOn(Dispatchers.IO)
|
||||
.conflate()
|
||||
|
||||
|
|
Loading…
Reference in a new issue