From dd4615f5730fefeeef55fa79aa559c41b3ca17bf Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Fri, 19 Sep 2014 18:29:06 +0000 Subject: [PATCH] reuse the code for getting the time a user joined --- labs/meteor-client/client/globals.coffee | 3 +++ labs/meteor-client/client/views/chat/chat_bar.coffee | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/labs/meteor-client/client/globals.coffee b/labs/meteor-client/client/globals.coffee index c45ac2307d..5cdb9333a6 100755 --- a/labs/meteor-client/client/globals.coffee +++ b/labs/meteor-client/client/globals.coffee @@ -20,6 +20,9 @@ meet?.meetingName else null +@getTimeOfJoining = -> + Meteor.Users.findOne({"user.userid": getInSession("userId")})?.user?.time_of_joining + # Finds the names of all people the current user is in a private conversation with # Removes yourself and duplicates if they exist @getPrivateChatees = -> diff --git a/labs/meteor-client/client/views/chat/chat_bar.coffee b/labs/meteor-client/client/views/chat/chat_bar.coffee index 72252c53dc..1961ccdf88 100755 --- a/labs/meteor-client/client/views/chat/chat_bar.coffee +++ b/labs/meteor-client/client/views/chat/chat_bar.coffee @@ -50,14 +50,14 @@ Template.chatbar.helpers after = before = greeting = [] if chattingWith is 'PUBLIC_CHAT' # find all public messages - before = Meteor.Chat.find({'message.chat_type': chattingWith, 'message.from_time': {$lt: String(Meteor.Users.findOne({"user.userid": getInSession("userId")})?.user?.time_of_joining)}}).fetch() - after = Meteor.Chat.find({'message.chat_type': chattingWith, 'message.from_time': {$gt: String(Meteor.Users.findOne({"user.userid": getInSession("userId")})?.user?.time_of_joining)}}).fetch() + before = Meteor.Chat.find({'message.chat_type': chattingWith, 'message.from_time': {$lt: String(getTimeOfJoining())}}).fetch() + after = Meteor.Chat.find({'message.chat_type': chattingWith, 'message.from_time': {$gt: String(getTimeOfJoining())}}).fetch() greeting = [ 'message': 'message': Template.chatbar.getChatGreeting(), 'from_username': 'System', - 'from_time': Meteor.Users.findOne({"user.userid": getInSession("userId")})?.user?.time_of_joining + 'from_time': getTimeOfJoining() 'from_color': '0x3399FF' # A nice blue in hex ] else