The app is for messaging, Firebase Firestore used I want to notify user if message is sent to server or not. To do this i added "sent (Boolean)" property to message entity , it works fine when i send message as (sent = false)
val messageToSend = TextMessage(editText_message.text.toString(), Calendar.getInstance().time,
FirebaseAuth.getInstance().currentUser!!.uid,
otherUserId, currentUser.name, false, null, false)
editText_message.setText("")
sendMessage(messageToSend, channelId)
fun sendMessage(message: TextMessage, channelId: String) {
FirebaseConstants.chatChannelsCollectionRef.document(channelId)
.collection("messages")
.add(message).addOnSuccessListener {
it.update(mapOf("sent" to true))
}
}
and i control it in my view holder
if (!message.sent) {
viewHolder.text_message_status_indicator.background = ContextCompat.getDrawable(context, R.drawable.ic_baseline_access_time_24)
}
The problem is when device is online again the message property is not updated (including sent = true)
Please help me with that problem