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