Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt

Use this file to discover all available pages before exploring further.

Support staff communicate with customers through the same chat system that customers use — no separate tool is required. Any user whose esSoporte flag is true in Realtime Database appears in the customer’s contact list as an available support agent. From their own device, staff see the full list of all registered users and can open a conversation with any of them.

Accessing the chat list

Staff can reach ListaChatActivity from Cuenta → Configuración → Soporte Chat:
binding.layoutConfig.btnSoporteChat.setOnClickListener {
    startActivity(Intent(mContext, ListaChatActivity::class.java))
}
When ListaChatActivity opens, it first checks whether the current user is a support agent:
private fun verificarMiRol() {
    val uid = FirebaseAuth.getInstance().currentUser?.uid ?: return
    FirebaseDatabase.getInstance().reference.child("Usuarios").child(uid)
        .child("esSoporte").get().addOnSuccessListener { snapshot ->
            soySoporte = snapshot.getValue(Boolean::class.java) ?: false
            listarUsuarios()
        }
}
The filtering logic then applies:
  • Support staff (soySoporte = true) — see every registered user so they can respond to anyone.
  • Regular customers (soySoporte = false) — see only users where esSoporte = true, effectively limiting their contact list to official staff accounts.

Responding to a customer

1

Open the chat list

Navigate to Cuenta → Configuración → Soporte Chat. All users are listed, ordered alphabetically by name.
2

Find the customer

Use the search bar at the top to filter by name if the list is long.
3

Tap a conversation

Tap any user row to open ChatActivity with that customer.
4

Send a reply

Type a text message or tap the image icon to send a photo from the gallery. Messages are written to Realtime Database immediately.

Chat storage path

Each conversation lives at a path derived from the two participants’ UIDs, sorted alphabetically and joined with an underscore:
fun rutaChat(receptorUid: String, emisorUid: String): String {
    val arrayUid = arrayOf(receptorUid, emisorUid)
    Arrays.sort(arrayUid)
    return "${arrayUid[0]}_${arrayUid[1]}"
}
The full Realtime DB path is therefore:
Chats/{uid_a}_{uid_b}/{messageId}

Unread message badges

ChatsUnreadCount tracks how many unread messages each conversation has for the current user. The counter is displayed as a badge on the user row in ListaChatActivity:
private fun obtenerContadorMensajes(userId: String, notifCount: TextView) {
    val miUid = FirebaseAuth.getInstance().uid ?: return
    FirebaseDatabase.getInstance().getReference("ChatsUnreadCount")
        .child(miUid).child(userId)
        .addValueEventListener(object : ValueEventListener {
            override fun onDataChange(snapshot: DataSnapshot) {
                val count = snapshot.getValue(Int::class.java) ?: 0
                if (count > 0) {
                    notifCount.text = if (count > 99) "99+" else count.toString()
                    notifCount.visibility = View.VISIBLE
                } else {
                    notifCount.visibility = View.GONE
                }
            }
            override fun onCancelled(error: DatabaseError) {}
        })
}

Online status

The app automatically sets Usuarios/{uid}/online to true when the app comes to the foreground and false when it goes to the background or is closed. Support staff can use this to tell at a glance whether a customer is currently active.

Blocking a disruptive user

Support staff can block a customer by long-pressing their row in ListaChatActivity. The option only appears when soySoporte = true and the target is not a support agent themselves. Confirming the action:
  1. Writes Usuarios/{myUid}/usuariosBloqueados/{blockedUid} = true in Realtime Database.
  2. Sends an automated chat message to the customer’s conversation:
    ”🚫 Has sido bloqueado por el personal de soporte. No podrás enviar más mensajes.”
The customer’s ChatActivity then detects the block and displays a banner:
} else if (bloqueadoPorOtro) {
    binding.tvBloqueado.text = "Has sido bloqueado por soporte"
}
Their message input is disabled so they cannot send further messages. To unblock a user, long-press their row again and select Quitar Bloqueo. This removes the usuariosBloqueados/{blockedUid} node.
Blocking a user prevents them from sending new messages but does not delete any existing chat history. Past messages remain visible to both parties in ChatActivity.

In-app popup notifications

When a new message arrives while support staff is on a different screen of the app, a PopupWindow slides in from the top-right corner of MainActivity. It shows the sender’s name, a preview of the message (or ”📷 Imagen Enviada” for image messages), and auto-dismisses after 4 seconds. Tapping the popup navigates directly to that customer’s ChatActivity.
Keep push notifications enabled on your device so you also receive OneSignal alerts when the app is fully in the background. The in-app popup only fires when the app is open; the push notification covers the rest.

Build docs developers (and LLMs) love