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


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

my page code:

  send(message) {
        this.uidLogin = this.auth.getLoggedUID();
        let newMessage: IMessage = {
          key:        null,
          userFromUid: this.uidLogin,
          userToUID: this.msgDatarecebido.idmensagemTo,
          timestamp: new Date().toString(),
          message: message,

database service:

  submitMessage(newMessage: IMessage) {

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);


The code you posted seems fine. Well, fine-ish. You’re hiding the preloader before the message is uploaded. But your double-submit is probably coming from somewhere else, e.g., you calling send twice without realizing it.


bingo! button click and form submit.

I must be tired… hehehe thanks for that bro!