diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 11db86c210..0b597bbaf9 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -529,6 +529,16 @@ class ChatActivity : private fun initObservers() { Log.d(TAG, "initObservers Called") + messageInputViewModel.messageQueueFlow.observe(this) { message -> + // TODO shouldn't be able save state + val temporaryChatMessage = ChatMessage() + temporaryChatMessage.jsonMessageId = -3 + temporaryChatMessage.actorId = "-3" + temporaryChatMessage.timestamp = (adapter?.items?.get(0)?.item as ChatMessage).timestamp + temporaryChatMessage.message = message + adapter?.addToStart(temporaryChatMessage, true) + } + this.lifecycleScope.launch { chatViewModel.getConversationFlow .onEach { conversationModel -> diff --git a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt index e74ebfc15b..41f69a0f38 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/viewmodels/MessageInputViewModel.kt @@ -124,6 +124,10 @@ class MessageInputViewModel @Inject constructor( val messageQueueSizeFlow: LiveData get() = _messageQueueSizeFlow.asLiveData() + private val _messageQueueFlow: MutableLiveData = MutableLiveData() + val messageQueueFlow: LiveData + get() = _messageQueueFlow + @Suppress("LongParameterList") fun sendChatMessage( roomToken: String, @@ -138,6 +142,7 @@ class MessageInputViewModel @Inject constructor( messageQueue.add(QueuedMessage(message, displayName, replyTo, sendWithoutNotification)) dataStore.saveMessageQueue(roomToken, messageQueue) _messageQueueSizeFlow.update { messageQueue.size } + _messageQueueFlow.postValue(message.toString()) return } @@ -274,6 +279,6 @@ class MessageInputViewModel @Inject constructor( companion object { private val TAG = MessageInputViewModel::class.java.simpleName - private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 100 + private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 500 } } diff --git a/app/src/main/res/layout/item_temporary_message.xml b/app/src/main/res/layout/item_temporary_message.xml index 96bf919d78..82fb3bb543 100644 --- a/app/src/main/res/layout/item_temporary_message.xml +++ b/app/src/main/res/layout/item_temporary_message.xml @@ -15,6 +15,14 @@ android:layout_marginRight="16dp" android:layout_marginBottom="2dp"> + +