Skip to content
Snippets Groups Projects
Commit d90a3385 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Remove UserManager and selectiveUser

parent bc0a1306
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
if roomData.t is 'd'
username = _.without roomData.usernames, Meteor.user().username
UserManager.addUser username
userData = {
name: Session.get('user_' + username + '_name')
......@@ -189,7 +188,6 @@ Template.room.helpers
for username in room?.usernames or []
if onlineUsers[username]?
utcOffset = onlineUsers[username]?.utcOffset
console.log utcOffset
if utcOffset?
if utcOffset > 0
utcOffset = "+#{utcOffset}"
......
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