Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9ab7f85
Change ChatSubscription to reference user as object
rodrigok Jun 3, 2015
110e7ef
Typing, sendMessage and sidebar profile fixed
rodrigok Jun 3, 2015
d35ae42
Create channels working
rodrigok Jun 3, 2015
80bcfaf
Fix indexes
rodrigok Jun 3, 2015
3f931f4
Create groups working
rodrigok Jun 3, 2015
5d1e287
View user info when click in user name or mention working
rodrigok Jun 3, 2015
639aa76
Direct messages working
rodrigok Jun 3, 2015
a2065dc
Read messages working
rodrigok Jun 3, 2015
7541925
Fix list of users in room
rodrigok Jun 3, 2015
650dfcc
Fixes #131
rodrigok Jun 3, 2015
e6bbd5a
Add user to room working
rodrigok Jun 3, 2015
4d2db61
More adjustments
rodrigok Jun 3, 2015
1e66311
Fix direct message creation
rodrigok Jun 3, 2015
45c2884
Fix users status
rodrigok Jun 3, 2015
c7f4d07
Prevent errors
rodrigok Jun 3, 2015
c86bb45
Prevent error
rodrigok Jun 3, 2015
109e747
Fix auto adition of new users in general room
rodrigok Jun 3, 2015
08dbb02
Edit last message working
rodrigok Jun 3, 2015
92bc7bd
Fix room rename
rodrigok Jun 3, 2015
5356a33
Little fixes
rodrigok Jun 3, 2015
fde2ab8
Create migration 3
rodrigok Jun 4, 2015
717a1e5
Comment transform of ChatRoom
rodrigok Jun 4, 2015
46617d4
Improve performance
rodrigok Jun 4, 2015
9925613
Performance improvements
rodrigok Jun 4, 2015
7d1906a
Merge remote-tracking branch 'origin/master' into user-references-as-…
rodrigok Jun 4, 2015
6015441
Back avatar url to correct path
rodrigok Jun 4, 2015
49655aa
Change avatar to 30px
rodrigok Jun 4, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/lib/RoomManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
ready: false

if myRoomActivity.ready()
if ChatSubscription.findOne { rid: roomId, uid: Meteor.userId() }, { reactive: false }
if ChatSubscription.findOne { rid: roomId, 'u._id': Meteor.userId() }, { reactive: false }
openedRooms[roomId].active = true
setRoomExpireExcept roomId
computation.invalidate()
Expand Down
14 changes: 7 additions & 7 deletions client/lib/UserManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

dep = new Tracker.Dependency

addUser = (userIds) ->
# console.log 'addUser', userIds if window.rocketUserDebug
userIds = [].concat userIds
for userId in userIds
unless users[userId]
users[userId] = 1
addUser = (usernames) ->
# console.log 'addUser', usernames if window.rocketUserDebug
usernames = [].concat usernames
for username in usernames
unless users[username]
users[username] = 1
dep.changed()

subscribeFn = ->
Expand All @@ -21,7 +21,7 @@
dep.depend()
subscribe.run()

init()
# init()

addUser: addUser
users: users
2 changes: 1 addition & 1 deletion client/lib/chatMessages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
self.typingTimeout = null

startEditingLastMessage = (rid, imput) ->
lastMessage = ChatMessage.findOne { rid: rid, t: {$exists: false}, uid: Meteor.userId() }, { sort: { ts: -1 } }
lastMessage = ChatMessage.findOne { rid: rid, t: {$exists: false}, 'u._id': Meteor.userId() }, { sort: { ts: -1 } }
if not lastMessage?
return

Expand Down
4 changes: 2 additions & 2 deletions client/methods/leaveRoom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Meteor.methods

update =
$pull:
uids: Meteor.userId()
usernames: Meteor.user().username

ChatSubscription.remove { rid: roomId, uid: Meteor.userId() }
ChatSubscription.remove { rid: roomId, 'u._id': Meteor.userId() }

ChatRoom.update roomId, update
5 changes: 3 additions & 2 deletions client/methods/sendMessage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ Meteor.methods
Tracker.nonreactive ->
now = new Date(Date.now() + TimeSync.serverOffset())

ChatMessage.upsert { rid: msg.rid, uid: Meteor.userId(), t: 't' },
ChatMessage.upsert { rid: msg.rid, t: 't' },
$set:
ts: now
msg: msg.message
'u.username': Meteor.user().username
$unset:
t: 1
expireAt: 1
Expand All @@ -15,7 +16,7 @@ Meteor.methods
Tracker.nonreactive ->
now = new Date(Date.now() + TimeSync.serverOffset())

ChatMessage.update { _id: msg.id, uid: Meteor.userId() },
ChatMessage.update { _id: msg.id, 'u._id': Meteor.userId() },
$set:
ets: now
msg: msg.message
4 changes: 3 additions & 1 deletion client/methods/typingStatus.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ Meteor.methods
filter =
t: 't'
rid: typingData.rid
uid: Meteor.userId()
$and: [{'u._id': Meteor.userId()}]

if start
msgData =
'$set':
expireAt: moment().add(30, 'seconds').toDate()
'$setOnInsert':
msg: '...'
'u._id': Meteor.userId()
'u.username': Meteor.user().username
ts: moment().add(1, 'years').toDate()

ChatMessage.upsert(filter, msgData)
Expand Down
43 changes: 17 additions & 26 deletions client/startup/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Meteor.startup ->
UserPresence.awayTime = 300000
UserPresence.start()

Session.setDefault('AvatarRandom', Date.now())
Session.setDefault('AvatarRandom', 0)

window.lastMessageWindow = {}
window.lastMessageWindowHistory = {}
Expand All @@ -26,42 +26,33 @@ Meteor.startup ->
TAPi18n.setLanguage(userLanguage)
moment.locale(userLanguage)

Meteor.users.find({}, { fields: { name: 1, pictures: 1, status: 1, emails: 1, phone: 1, services: 1 } }).observe
Meteor.users.find({}, { fields: { name: 1, username: 1, pictures: 1, status: 1, emails: 1, phone: 1, services: 1 } }).observe
added: (user) ->
Session.set('user_' + user._id + '_name', user.name)
Session.set('user_' + user._id + '_status', user.status)
Session.set('user_' + user._id + '_emails', user.emails)
Session.set('user_' + user._id + '_phone', user.phone)
Session.set('user_' + user.username + '_status', user.status)

UserAndRoom.insert({ type: 'u', uid: user._id, name: user.name})
# UserAndRoom.insert({ type: 'u', uid: user._id, username: user.username, name: user.name})
changed: (user) ->
Session.set('user_' + user._id + '_name', user.name)
Session.set('user_' + user._id + '_status', user.status)
Session.set('user_' + user._id + '_emails', user.emails)
Session.set('user_' + user._id + '_phone', user.phone)
Session.set('user_' + user.username + '_status', user.status)

UserAndRoom.update({ uid: user._id }, { $set: { name: user.name } })
# UserAndRoom.update({ uid: user._id }, { $set: { username: user.username, name: user.name } })
removed: (user) ->
Session.set('user_' + user._id + '_name', null)
Session.set('user_' + user._id + '_status', null)
Session.set('user_' + user._id + '_emails', null)
Session.set('user_' + user._id + '_phone', null)
Session.set('user_' + user.username + '_status', null)

UserAndRoom.remove({ uid: user._id })
# UserAndRoom.remove({ uid: user._id })

ChatRoom.find({ t: { $ne: 'd' } }, { fields: { t: 1, name: 1 } }).observe
added: (room) ->
roomData = { type: 'r', t: room.t, rid: room._id, name: room.name }
# ChatRoom.find({ t: { $ne: 'd' } }, { fields: { t: 1, name: 1 } }).observe
# added: (room) ->
# roomData = { type: 'r', t: room.t, rid: room._id, name: room.name }

UserAndRoom.insert(roomData)
changed: (room) ->
UserAndRoom.update({ rid: room._id }, { $set: { t: room.t, name: room.name } })
removed: (room) ->
UserAndRoom.remove({ rid: room._id })
# UserAndRoom.insert(roomData)
# changed: (room) ->
# UserAndRoom.update({ rid: room._id }, { $set: { t: room.t, name: room.name } })
# removed: (room) ->
# UserAndRoom.remove({ rid: room._id })

Tracker.autorun ->
rooms = []
ChatSubscription.find({ uid: Meteor.userId() }, { fields: { rid: 1 } }).forEach (sub) ->
ChatSubscription.find({ 'u._id': Meteor.userId() }, { fields: { rid: 1 } }).forEach (sub) ->
rooms.push sub.rid

ChatRoom.find({ _id: $in: rooms }).observe
Expand Down
10 changes: 5 additions & 5 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ input.search {
}
}

form.search-form {
.search-form {
position: relative;
}

Expand Down Expand Up @@ -668,8 +668,8 @@ a.github-fork {
.avatar-image {
height: 100%;
width: 100%;
min-height: 40px;
min-width: 40px;
min-height: 20px;
min-width: 20px;
display: block;
background-color: transparent;
background-size: cover;
Expand Down Expand Up @@ -2069,7 +2069,7 @@ a.github-fork {
}
}

@user-image-square: 40px;
@user-image-square: 30px;
.user-image {
margin: 4px;
height: @user-image-square;
Expand Down Expand Up @@ -2146,7 +2146,7 @@ a.github-fork {
a{
.cf_;
padding: 5px 0;
height: auto;
height: 30px;
background-color: transparent;
display: block;
> div{
Expand Down
16 changes: 7 additions & 9 deletions client/views/app/chatMessageDashboard.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Template.chatMessageDashboard.helpers
own: ->
return 'own' if this.data.uid is Meteor.userId()
return 'own' if this.data.u?._id is Meteor.userId()

username: ->
if this.uid?
return Session.get('user_' + this.uid + '_name')
return this.u.username

isSystemMessage: ->
return this.t in ['s', 'p', 'f', 'r', 'au', 'ru', 'ul', 'nu', 'wm']
Expand All @@ -30,8 +29,8 @@ Template.chatMessageDashboard.helpers
message: ->
if this.by
UserManager.addUser(this.by)
else if this.uid
UserManager.addUser(this.uid)
else if this.u?.username
UserManager.addUser this.u.username
switch this.t
when 'p' then "<i class='icon-link-ext'></i><a href=\"#{this.url}\" target=\"_blank\">#{this.msg}</a>"
when 'r' then t('chatMessageDashboard.Room_name_changed', { room_name: this.msg, user_by: Session.get('user_' + this.by + '_name') }) + '.'
Expand Down Expand Up @@ -76,10 +75,9 @@ Template.chatMessageDashboard.events
Meteor.defer ->
$('.input-message-editing').select()

# TODO open flextab with user info
# 'click .mention-link': ->
# Session.set('flexOpened', true)
# Session.set('showUserInfo', $(e.currentTarget).data('username'))
'click .mention-link': (e) ->
Session.set('flexOpened', true)
Session.set('showUserInfo', $(e.currentTarget).data('username'))

Template.chatMessageDashboard.onRendered ->
chatMessages = $('.messages-box .wrapper')
Expand Down
6 changes: 3 additions & 3 deletions client/views/app/chatMessageDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{{#if isSystemMessage}}
<p class="system">{{{message}}}</p>
{{else}}
<a class="thumb user-card-message" href="#" data-userid="{{uid}}" tabindex="1">
{{> avatar userId=uid}}
<a class="thumb user-card-message" href="#" data-username="{{username}}" tabindex="1">
{{> avatar username=username}}
</a>
<a class="user user-card-message" href="#" data-userid="{{uid}}" tabindex="1">{{username}}</a>
<a class="user user-card-message" href="#" data-username="{{username}}" tabindex="1">{{username}}</a>
<span class="time">
{{time}}
{{#if ets}}
Expand Down
Loading