Skip to content
Snippets Groups Projects
Commit 5c8d5e6c authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Merge pull request #392 from RocketChat/user-timezone

User timezone
parents d6410f52 321a7341
No related branches found
No related tags found
No related merge requests found
@UserManager = new class
users = {}
dep = new Tracker.Dependency
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 = ->
return true
# Meteor.subscribe 'selectiveUsers', users
subscribe = new DelayedTask subscribeFn, 100, 1000
init = ->
Tracker.autorun ->
dep.depend()
subscribe.run()
# init()
addUser: addUser
users: users
...@@ -76,7 +76,6 @@ Template.room.helpers ...@@ -76,7 +76,6 @@ Template.room.helpers
if roomData.t is 'd' if roomData.t is 'd'
username = _.without roomData.usernames, Meteor.user().username username = _.without roomData.usernames, Meteor.user().username
UserManager.addUser username
userData = { userData = {
name: Session.get('user_' + username + '_name') name: Session.get('user_' + username + '_name')
...@@ -189,7 +188,6 @@ Template.room.helpers ...@@ -189,7 +188,6 @@ Template.room.helpers
for username in room?.usernames or [] for username in room?.usernames or []
if onlineUsers[username]? if onlineUsers[username]?
utcOffset = onlineUsers[username]?.utcOffset utcOffset = onlineUsers[username]?.utcOffset
console.log utcOffset
if utcOffset? if utcOffset?
if utcOffset > 0 if utcOffset > 0
utcOffset = "+#{utcOffset}" utcOffset = "+#{utcOffset}"
......
...@@ -13,3 +13,4 @@ Meteor.publish 'activeUsers', -> ...@@ -13,3 +13,4 @@ Meteor.publish 'activeUsers', ->
fields: fields:
username: 1 username: 1
status: 1 status: 1
utcOffset: 1
Meteor.publish 'selectiveUsers', (usernames) ->
unless this.userId
return this.ready()
console.log '[publish] selectiveUsers -> '.green, 'userIds:', userIds
self = this
query =
username: $exists: true
options =
fields:
name: 1
username: 1
status: 1
utcOffset: 1
cursor = Meteor.users.find query, options
observer = cursor.observeChanges
added: (id, record) ->
if usernames[record.username]?
self.added 'users', id, record
changed: (id, record) ->
if usernames[record.username]?
self.changed 'users', id, record
removed: (id) ->
if usernames[record.username]?
self.removed 'users', id
this.ready()
this.onStop ->
observer.stop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment