Search code examples
androidfirebasefirebase-realtime-databasefirebaseui

How to fetch indexed data from more than one endpoints when using FirebaseRecycler?


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.


Solution

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

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