|  | @@ -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();
 | 
	
		
			
				|  |  |      // see if we can find a chat object in the database
 | 
	
		
			
				|  |  |      // to which we'll add the message
 | 
	
		
			
				|  |  | -    const chat = Chats.findOne({_id: Session.get("chatId")});
 | 
	
		
			
				|  |  | +    const chat = Chats.findOne({ _id: Session.get("chatId") });
 | 
	
		
			
				|  |  |      if (chat) {// ok - we have a chat to use
 | 
	
		
			
				|  |  |        let msgs = chat.messages; // pull the messages property
 | 
	
		
			
				|  |  |        if (!msgs) {// no messages yet, create a new array
 | 
	
	
		
			
				|  | @@ -27,7 +26,10 @@ Template.chat_page.events({
 | 
	
		
			
				|  |  |        // is a good idea to insert data straight from the form
 | 
	
		
			
				|  |  |        // (i.e. the user) into the database?? certainly not.
 | 
	
		
			
				|  |  |        // push adds the message to the end of the array
 | 
	
		
			
				|  |  | -      msgs.push({ text: event.target.chat.value });
 | 
	
		
			
				|  |  | +      msgs.push({
 | 
	
		
			
				|  |  | +        text: event.target.chat.value,
 | 
	
		
			
				|  |  | +        sender: Meteor.userId()
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  |        // reset the form
 | 
	
		
			
				|  |  |        event.target.chat.value = "";
 | 
	
		
			
				|  |  |        // put the messages array onto the chat object
 |