You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in the current implementation, SlackClient#loadUsers() will typically be called twice each time Hubot starts up. the first time, immediately. the second time, after the brain's storage connection is completed and the 'loaded' event is fired. this is wasteful.
the second problem is that subscribing to user presence is tied to the brain 'loaded' event, which seems incorrect. will this ever fire if the brain doesn't have any backing storage (just using memory)? will it only subscribe to a partial list of users (those who were in the brain when it loaded but not those who are modified after SlackClient#loadUsers() completes)?
with the introduction of the Bluebird dependency, it seems like we can use Promises to create a better solution. here's some pseudo-code.
# in SlackBot constructor add `subscribeAllUserPresence` boolean option default to true# in SlackBot#run()loadUsers=newPromise (resolve, reject) =>@client.loadUsers (error, res) =>if (error)
returnreject(error)
resolve(res)
brainHasStorage=true# no idea how to get this valueinitialBrainLoad=not brainHasStorage ?Promise.resolve() :newPromise (resolve, reject) =>loaded=false@robot.brain.on'loaded', () ->ifnot loaded
loaded=trueresolve()
Promise.all([loadUsers, initialBrainLoad])
.then ([res]) =>@usersLoaded(null, res)
@presenceSub()
.catchconsole.error# TODO# in SlackBot#presenceSub()if@options.subscribeAllUserPresence# ... current implementation here# in SlackBot#updateUserInBrain()if@options.subscribeAllUserPresence&& userNotInBrain
# add a new presence subscription for a single user
should we be handling team_joinevents too?
should we centralize the two places where @robot.brain.userForId are called?
Requirements (place an x in each of the [ ])
I've read and understood the Contributing guidelines and have done my best effort to follow them.
Description
in the current implementation,
SlackClient#loadUsers()
will typically be called twice each time Hubot starts up. the first time, immediately. the second time, after the brain's storage connection is completed and the'loaded'
event is fired. this is wasteful.the second problem is that subscribing to user presence is tied to the brain
'loaded'
event, which seems incorrect. will this ever fire if the brain doesn't have any backing storage (just using memory)? will it only subscribe to a partial list of users (those who were in the brain when it loaded but not those who are modified afterSlackClient#loadUsers()
completes)?with the introduction of the Bluebird dependency, it seems like we can use Promises to create a better solution. here's some pseudo-code.
should we be handling
team_join
events too?should we centralize the two places where
@robot.brain.userForId
are called?Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: