Implemented notify_clients_after_touch for later.
This commit is contained in:
parent
4a669df039
commit
94cae01973
1 changed files with 34 additions and 1 deletions
|
@ -518,6 +518,7 @@ end
|
|||
def self.notify_clients_support
|
||||
after_create :notify_clients_after_create
|
||||
after_update :notify_clients_after_update
|
||||
# after_touch :notify_clients_after_touch
|
||||
after_touch :notify_clients_after_update
|
||||
after_destroy :notify_clients_after_destroy
|
||||
end
|
||||
|
@ -531,6 +532,7 @@ used as callback in model file
|
|||
class OwnModel < ApplicationModel
|
||||
after_create :notify_clients_after_create
|
||||
after_update :notify_clients_after_update
|
||||
after_touch :notify_clients_after_touch
|
||||
after_destroy :notify_clients_after_destroy
|
||||
|
||||
[...]
|
||||
|
@ -559,6 +561,7 @@ used as callback in model file
|
|||
class OwnModel < ApplicationModel
|
||||
after_create :notify_clients_after_create
|
||||
after_update :notify_clients_after_update
|
||||
after_touch :notify_clients_after_touch
|
||||
after_destroy :notify_clients_after_destroy
|
||||
|
||||
[...]
|
||||
|
@ -580,6 +583,35 @@ class OwnModel < ApplicationModel
|
|||
|
||||
=begin
|
||||
|
||||
notify_clients_after_touch after model got touched
|
||||
|
||||
used as callback in model file
|
||||
|
||||
class OwnModel < ApplicationModel
|
||||
after_create :notify_clients_after_create
|
||||
after_update :notify_clients_after_update
|
||||
after_touch :notify_clients_after_touch
|
||||
after_destroy :notify_clients_after_destroy
|
||||
|
||||
[...]
|
||||
|
||||
=end
|
||||
|
||||
def notify_clients_after_touch
|
||||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
logger.debug "#{ self.class.name }.find(#{ self.id }) notify TOUCH " + self.updated_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Sessions.broadcast(
|
||||
:event => class_name + ':touch',
|
||||
:data => { :id => self.id, :updated_at => self.updated_at }
|
||||
)
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
notify_clients_after_destroy after model got destroyed
|
||||
|
||||
used as callback in model file
|
||||
|
@ -587,6 +619,7 @@ used as callback in model file
|
|||
class OwnModel < ApplicationModel
|
||||
after_create :notify_clients_after_create
|
||||
after_update :notify_clients_after_update
|
||||
after_touch :notify_clients_after_touch
|
||||
after_destroy :notify_clients_after_destroy
|
||||
|
||||
[...]
|
||||
|
@ -1072,4 +1105,4 @@ destory object dependencies, will be executed automatically
|
|||
def destroy_dependencies
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue