Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229115

Message / Chat - Input in firebase - record getting duplicated - Ionic Firebase

$
0
0

I wonder what am i doing wrong here to get 2 inserts instead of one:

my page code:

  send(message) {
    this.loader.displayPreloader();
        this.uidLogin = this.auth.getLoggedUID();
        let newMessage: IMessage = {
          key:        null,
          userFromUid: this.uidLogin,
          userToUID: this.msgDatarecebido.idmensagemTo,
          timestamp: new Date().toString(),
          message: message,
        };
        this.db.submitMessage(newMessage);
        this.loader.hidePreloader();
        this.scrollToBottom();
      }

database service:

  submitMessage(newMessage: IMessage) {
    this.messagesRef.push(newMessage);
}

database scheme1

i've tried different forms but still always getting duplicated, for example:

submitMessage(newMessage: IMessage) {
      var newMessageRef = this.messagesRef.push();
    return newMessageRef.set(newMessage);
}

Viewing all articles
Browse latest Browse all 229115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>