|
@@ -1,13 +1,12 @@
|
|
|
|
|
|
Template.chat_page.helpers({
|
|
|
messages: function () {
|
|
|
- console.log("messages context", this);
|
|
|
const chat = Chats.findOne({ _id: Session.get("chatId") });
|
|
|
+ console.log("messages context", this, chat.messages);
|
|
|
return chat.messages;
|
|
|
},
|
|
|
|
|
|
other_user: function () {
|
|
|
- return this;
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -18,7 +17,7 @@ Template.chat_page.events({
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
|
- const chat = Chats.findOne({_id: Session.get("chatId")});
|
|
|
+ const chat = Chats.findOne({ _id: Session.get("chatId") });
|
|
|
if (chat) {
|
|
|
let msgs = chat.messages;
|
|
|
if (!msgs) {
|
|
@@ -27,7 +26,10 @@ Template.chat_page.events({
|
|
|
|
|
|
|
|
|
|
|
|
- msgs.push({ text: event.target.chat.value });
|
|
|
+ msgs.push({
|
|
|
+ text: event.target.chat.value,
|
|
|
+ sender: Meteor.userId()
|
|
|
+ });
|
|
|
|
|
|
event.target.chat.value = "";
|
|
|
|