Meteor/Mongodb observable collection getting called twice


#1

I am using Meteor/Mongo to create a chat app.

I have the following code, but my problem is when I add a row to the MongoDb, the observe gets triggered twice, when I only expect it to do so once.

The addMessage function gets called twice. Is there a way to prevent addMessage from being called more than once for a particular message?

On the client:

private messages: Mongo.Cursor<Message>;

sendMessage(): void {
      this.messages.observe({
        added: (message) => this.addMessage(message)
      });    
      this.call('addMessage', this.senderId, this.activeChat._id, this.messageString);    
}

On the server:

  addMessage(senderId: string, chatId: string, content: string): void {
    Messages.insert({
      chatId: chatId,
      senderId: senderId,
      content: content,
      readByReceiver: false,
      createdAt: new Date()
    });
  },