Load more message or pagination action for chat messages

398 views
Skip to first unread message

Claudio Marrero

unread,
Dec 4, 2016, 12:28:06 PM12/4/16
to Firebase Google Group
var ref = firebase.database().ref("messages/"+userId+"/"+agencyId);

       
.orderByChild('timestamp')
       
.limitToLast(2);

        scope
.messages = $firebaseArray(ref);

        scope
.loadMore = function(){

           
ref
               
.orderByChild('timestamp')
               
.limitToLast(4);

            scope
.messages = $firebaseArray(ref);
       
};

Limit is undefind, and limitToLast doesnt help with this aproach.

I need to load the older messages upside to the messages that already loaded. Like a history list messages.

The new "google" firebase doesnt have the functions that I found to make this aproach.

Best
C

Kato Richardson

unread,
Dec 5, 2016, 2:06:24 PM12/5/16
to Firebase Google Group
Hi Claudio,

Unclear what you mean by "limitToLast doesn't help with this approach". What is it you're trying to achieve?

Note that you can't use multiple orderBy() criteria on a ref. So in your loadMore method, you should be accessing the original ref, not the query that already has an orderBy() and limitToLast() on it.

Housekeeping: It looks like you posted this same question in the issue tracker here. As a general rule of etiquette, you can show respect for the community's time by always letting developers know when you cross-post your questions, so we don't duplicate effort.

☼, Kato


C

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/50981b6c-c090-4015-9883-3cb2633dc48d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Reply all
Reply to author
Forward
0 new messages