diff --git a/client/views/app/chatWindowDashboard.coffee b/client/views/app/chatWindowDashboard.coffee index c72c2f2d80c..3f10b53a079 100644 --- a/client/views/app/chatWindowDashboard.coffee +++ b/client/views/app/chatWindowDashboard.coffee @@ -17,9 +17,12 @@ Template.chatWindowDashboard.helpers console.log 'chatWindowDashboard.helpers favorite' if window.rocketDebug sub = ChatSubscription.findOne { rid: this._id } return 'icon-star favorite-room' if sub?.f? and sub.f - return 'icon-star-empty' + subscribed: -> + console.log 'chatWindowDashboard.helpers subscribed' if window.rocketDebug + return ChatSubscription.findOne { rid: this._id } + messages: -> console.log 'chatWindowDashboard.helpers messages' if window.rocketDebug window.lastMessageWindow[this._id] = undefined @@ -298,6 +301,12 @@ Template.chatWindowDashboard.events event.preventDefault() Meteor.call 'toogleFavorite', this._id, !$('i', event.currentTarget).hasClass('favorite-room') + 'click .join': (event) -> + console.log 'chatWindowDashboard click .join' if window.rocketDebug + event.stopPropagation() + event.preventDefault() + Meteor.call 'joinRoom', this._id + "click .burger": -> console.log 'chatWindowDashboard click .burger' if window.rocketDebug chatContainer = $("#rocket-chat") diff --git a/client/views/app/chatWindowDashboard.html b/client/views/app/chatWindowDashboard.html index 23334288a0d..2e570a773ef 100644 --- a/client/views/app/chatWindowDashboard.html +++ b/client/views/app/chatWindowDashboard.html @@ -55,39 +55,46 @@
@@ -128,9 +135,9 @@ {{#with userActiveByUsername .}}
  • - {{> avatar username=username}} -

    {{username}}

    -
    + {{> avatar username=username}} +

    {{username}}

    +
  • {{/with}} {{/each}} diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 72d76bc2512..b4784ecb316 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -54,7 +54,9 @@ "Send_Message" : "Send Message", "Showing_online_users" : "Showing __total_online__ of __total__ users", "Start_of_conversation" : "Start of conversation", - "View_All" : "View All" + "View_All" : "View All", + "you_are_in_preview_mode_of": "You are in preview mode of", + "join": "Join" }, "footer" : { "Follow_social_profiles" : "Follow our social profiles, fork us on github and share your thoughts about the rocket.chat app on our trello board.", @@ -164,4 +166,4 @@ "Use_uploaded_avatar" : "Use uploaded avatar", "Select_file" : "Select file" } -} \ No newline at end of file +} diff --git a/server/methods/joinRoom.coffee b/server/methods/joinRoom.coffee new file mode 100644 index 00000000000..6af79d9b596 --- /dev/null +++ b/server/methods/joinRoom.coffee @@ -0,0 +1,45 @@ +Meteor.methods + joinRoom: (rid) -> + + room = ChatRoom.findOne rid + + if room.t isnt 'c' + throw new Meteor.Error 403, '[methods] joinRoom -> Not allowed' + + # verify if user is already in room + # if room.usernames.indexOf(data.username) is -1 + + now = new Date() + + update = + $push: + usernames: + $each: [data.username] + $sort: 1 + + newUser = Meteor.users.findOne username: data.username + + ChatRoom.update data.rid, update + + ChatSubscription.insert + rid: data.rid + ts: now + name: room.name + t: room.t + open: true + alert: true + unread: 1 + u: + _id: newUser._id + username: data.username + + ChatMessage.insert + rid: data.rid + ts: now + t: 'au' + msg: newUser.name + u: + _id: newUser._id + username: data.username + + return true