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