Class: Loco::NotificationCenterChannel

Inherits:
ApplicationCable::Channel
  • Object
show all
Defined in:
app/channels/loco/notification_center_channel.rb

Instance Method Summary collapse

Instance Method Details

#receive(data) ⇒ Object



22
23
24
25
# File 'app/channels/loco/notification_center_channel.rb', line 22

def receive(data)
  update_connections if data['loco'] && data['loco']['connection_check']
  NotificationCenter.new.received_message permissions, data
end

#subscribedObject



5
6
7
8
9
10
11
12
# File 'app/channels/loco/notification_center_channel.rb', line 5

def subscribed
  return unless loco_permissions.is_a?(Array)

  stream_for_resources
  return if loco_permissions.compact.size > 1

  SenderJob.perform_later @uuid, loco: { start_ajax_polling: true }
end

#unsubscribedObject



14
15
16
17
18
19
20
# File 'app/channels/loco/notification_center_channel.rb', line 14

def unsubscribed
  loco_permissions.each do |resource|
    next if resource.nil? || resource.is_a?(String)

    UuidJob.perform_later serialize_resource(resource), @uuid, 'del'
  end
end