Hello i am trying to build a chat live in a meteor App
well All it’s fine but i am having a little problem in showing the messages of one conversation in two seperated div “sent” and repley
this is a screenshot of my app
well in my helper i am getting the messages of a clicked conversation, i have a field called TypeMessage; if TypeMessage==“1” then i want to show that message in the sent div
and if TypeMessage==“2” then i want to show that message in the repley div
this is my helper code
allMessagesOfConversation: function() {
Meteor.subscribe('allConversations');
Meteor.subscribe('allMessages');
Meteor.subscribe('allContacts');
return Messages.find({idConversation: Session.get('conversationId')},{sort: {createdAt: -1}}).map(function(message, messageSender) {
if (message.typeMessage ==="1") {
message.isFirst=true;
return messageSender;
}else {
return message;
}
});
},
and this is my template code
<div class="messages">
{{#each allMessagesOfConversation}}
<ul>
{{#if isFirst}}
<li class="sent">
<img src="http://emilcarlsson.se/assets/mikeross.png" alt="" />
<p>{{message}} </p>
</li>
{{else}}
<li class="replies">
<img src="http://emilcarlsson.se/assets/harveyspecter.png" alt="" />
<p>{{message}}</p>
</li>
{{/if}}
</ul>
{{/each}}
</div>
correct me please