Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes to update user on the fly
Signed-off-by: Akash Manohar J <akash@akash.im>
  • Loading branch information
HashNuke committed Apr 5, 2012
1 parent 4d5cfa7 commit 96f7d77
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Expand Up @@ -26,6 +26,7 @@ class Kandan.Broadcasters.FayeBroadcaster


processEventsForUser: (eventName, data)->
console.log "event:", eventName
$(document).data('active_users', data.extra.active_users)
Kandan.Data.ActiveUsers.runCallbacks("change", data)

Expand Down
4 changes: 3 additions & 1 deletion app/models/user_observer.rb
@@ -1,7 +1,9 @@
class UserObserver < ActiveRecord::Observer

def after_save(user)
ActiveUsers.update_user(user) if user.first_name_changed? or user.last_name_changed?
if defined?(ActiveUsers)
::ActiveUsers.update_user(user) if user.first_name_changed? or user.last_name_changed?
end
end

end
2 changes: 1 addition & 1 deletion config/initializers/kandan.rb
Expand Up @@ -8,7 +8,7 @@
module Kandan
def self.devise_modules
standard = [:database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable]
:recoverable, :rememberable, :trackable, :validatable, :token_authenticatable]
bushido = [:bushido_authenticatable, :trackable, :token_authenticatable]

::Bushido::Platform.on_bushido? ? bushido : standard
Expand Down
4 changes: 2 additions & 2 deletions lib/active_users.rb
Expand Up @@ -47,7 +47,7 @@ def find_by_user_id(user_id)
def update_user(user)
if find_by_user_id(user.id)
@@users[user.id][:user] = user

publish_message "update", user
end
end

Expand All @@ -61,7 +61,7 @@ def all

def publish_message(event, user)
Channel.send("user_#{event}", user) if not event == "update"

FAYE_CLIENT.publish("/app/activities", {
:event => "user##{event}",
:entity => user,
Expand Down

0 comments on commit 96f7d77

Please sign in to comment.