One option is to make a method call that just updates the latest user joined message.

function formatJoinMessage(username,count) {...}

if (Meteor.isServer) Meteor.startup(function () {Chats._ensureIndex({modified:-1}); ...});

Meteor.methods({
    join:function() {
        var joinMessage = Chats.find({type:MESSAGE_TYPE_JOINED,userId:this.userId}).sort({modified:-1}).fetch()[0];
        if (joinMessage)
            Chats.update({_id:joinMessage._id},{$inc:{joins:1},$set:{text:formatJoinMessage(this.userId,joinMessage.joins+1),modified:new Date()});
        else
            Chats.insert({user:this.userId,joins:1,modified:new Date(),text:formatJoinMessage(this.userId,1)});
    }
)};


Don't want to change the server doc? That's okay, but conceptually a chat join isn't a chat message. So you should definitely have a meta field for stuff like this in your chat documents.

But supposing you don't want to do that. I'd do something like this:

var userIdToName = function(userId) {...}; // some kind of userId to name helper

Template.chatroom.msg = function() {
  var messages = Chat.findOne(Session.get("currentChat")).messages; // msg in your code?
  return _.reduce(messages,function (newMessages, currentMessage) {
    var lastMsg = newMessages[newMessages.length-1];
    if (currentMessage.type == MESSAGE_TYPES_JOIN) {
       if (lastMsg &amp;&amp; lastMsg.type == MESSAGE_TYPES_JOIN &amp;&amp; currentMessage.user == lastMsg.user) {
          currentMessage.timesJoined = lastMsg.timesJoined+1;
          newMessages.shift();
       } else {
          currentMessage.timesJoined = 1;
       }
       currentMessage.chatMsg = userIdToName(lastMsg.user) + " joins the chat &amp;mult;" + currentMessage.timesJoined.toString();
    }
    return newMessages.concat(currentMessage);
  },[]);
}


This is a bit of a doozy. Suffice it to say, it "reduces" all the join messages it finds in the chat's current messages down to one message. You dynamically add the property timesJoined; it does not appear in the document. But you should have a type field that lets you know the difference between a join message and a regular message is.

If you don't even have that metadata at minimum, then your chat application isn't going to work very well. Don't hesitate to change your model!

Meteor renderList intercept? client side
About: http://stackoverflow.com/review/suggested-edits/1962857

Recently, I've been suggesting a lot of edits - to make the site better. Scrolling through the list of my suggestions, I saw that this was rejected: http://stackoverflow.com/review/suggested-edits/1962857 - mostly with the 


  This edit is too minor; suggested edits should be substantive improvements addressing multiple issues in the post.


reason.

However, if you look at the edit, it is substantial. It clarifies the question, and provides grammar and formatting fixes.

Any help?
