Ionic Firebase Index

#1

Hi. I have a problem. I used firebase for get realtime data. But when I run the function data is coming;

—>4th message
—>first message
—>second message
—>third message

and going back to previous page, I’m opening the message page again all messages are coming correctly. only when I first opened it get message irregular

—>first message
—>second message
—>third message
—>4th message

what can I do about it
Thank you for your help

this.vt.collection("message").where("room", "==", roomNUmber)
        .orderBy("date", "asc")
        .onSnapshot(function (snapshot) {
          snapshot.docChanges().forEach(function (change) {
            
         console.log(change);
            if (change.type === "added") {
...
..
.