Only send initial message once

This commit is contained in:
perroned 2014-08-13 12:16:27 -07:00
parent b830735e08
commit 9a2990fe4a
2 changed files with 18 additions and 17 deletions

View File

@ -81,23 +81,24 @@ Template.message.rendered = -> # When a message has been added and finished rend
$('#chatbody').scrollTop($('#chatbody')[0].scrollHeight) $('#chatbody').scrollTop($('#chatbody')[0].scrollHeight)
Template.optionsBar.events Template.optionsBar.events
'click .private-chat-user-entry': (event) -> # clicked a user's name to begin private chat 'click .private-chat-user-entry': (event) -> # clicked a user's name to begin private chat
setInSession 'display_chatPane', true setInSession 'display_chatPane', true
setInSession "inChatWith", @userId setInSession "inChatWith", @userId
me = getInSession("userId")
messageForServer = if Meteor.Chat.find({'message.chat_type': 'PRIVATE_CHAT', $or: [{'message.from_userid': me, 'message.to_userid': @userId},{'message.from_userid': @userId, 'message.to_userid': me}]}).fetch().length is 0
"message": "#{getUsersName()} has joined private chat with #{@user.name}." messageForServer =
"chat_type": "PRIVATE_CHAT" "message": "#{getUsersName()} has joined private chat with #{@user.name}."
"from_userid": getInSession("userId") "chat_type": "PRIVATE_CHAT"
"from_username": getUsersName() "from_userid": me
"from_tz_offset": "240" "from_username": getUsersName()
"to_username": @user.name "from_tz_offset": "240"
"to_userid": @userId "to_username": @user.name
"from_lang": "en" "to_userid": @userId
"from_time": getTime() "from_lang": "en"
"from_color": "0" "from_time": getTime()
"from_color": "0"
Meteor.call "sendChatMessagetoServer", getInSession("meetingId"), messageForServer Meteor.call "sendChatMessagetoServer", getInSession("meetingId"), messageForServer
Template.tabButtons.events Template.tabButtons.events
'click .close': (event) -> # user closes private chat 'click .close': (event) -> # user closes private chat

View File

@ -37,7 +37,7 @@
<!-- Displays the list of options available --> <!-- Displays the list of options available -->
<template name="optionsBar"> <template name="optionsBar">
<p>Select a person to chat with privately</p> <p>&nbsp;&nbsp;Select a person to chat with privately</p>
<div class="private-chat-user-box"> <div class="private-chat-user-box">
{{#Layout template="scrollWindow" id="privateChatUserScrollWindow"}} {{#Layout template="scrollWindow" id="privateChatUserScrollWindow"}}
{{#contentFor region="scrollContents"}} {{#contentFor region="scrollContents"}}