0

I am exploring FirebaseUI to build a chat list which shows list of all chats for a user along with the last message and name and profile picture of the participant. My data model looks something like this:

  users:
     userid1:
       name: MyName
       profilePicUrl: <here>
     userid2:
       name: HisName
       profilePicUrl: <here>

   userchats:
      userid1:
         chatgrp1
         chatgrp2

   chatgroups:
      chatgrp1:
        participants: <userId2>
        lastMessage: "This..."

I can use indexed query to get list of chatgroups for a user and then contents for each. But i also need the name and profile pic for the participants. I am not able to figure out how to do that with firebaseUI. Is this possible using FirebaseUI?

I am doing something like this presently:

Query keyQuery = FirebaseDatabase.getInstance()
            .getReference()
            .child("userchats/userid1");

    DatabaseReference dataRef = FirebaseDatabase.getInstance()
            .getReference("chatgroups");

    FirebaseRecyclerOptions<FirebaseConversationRecord> options = new FirebaseRecyclerOptions.Builder<FirebaseConversationRecord>()
            .setIndexedQuery(keyQuery, dataRef, FirebaseConversationRecord.class)
            .build();

I cannot de-normalize the user data in this case because user might update his name or pic and that should get reflected for all his chats. Please suggest how i can achieve this? I am open to schema changes also.

Adi
  • 4,149
  • 4
  • 25
  • 41
  • 1
    If you want at some point to try [Cloud Firestore](https://firebase.google.com/docs/firestore/), here you can find a tutorial on how to can create a complete and functional [Chat App](https://www.youtube.com/playlist?list=PLn2n4GESV0Ak1HiH0tTPTJXsOEy-5v9qb). In the meanwhile, if don't want to denormilize your data then you should only keep references but this implies extra database call. See **[here](https://stackoverflow.com/questions/53053768/what-is-the-correct-way-to-structure-this-kind-of-data-in-firestore/53057707)** more details about pros and cons. – Alex Mamo Nov 19 '18 at 09:37

1 Answers1

0

Based on discussions with Firebase-UI team, this feature is not yet supported.

https://github.com/firebase/FirebaseUI-Android/issues/1534

Adi
  • 4,149
  • 4
  • 25
  • 41