Class: Signum::Signal

Inherits:
ApplicationRecord show all
Defined in:
app/models/signum/signal.rb

Instance Method Summary collapse

Instance Method Details

#broadcast_createObject



11
12
13
14
15
16
17
18
19
# File 'app/models/signum/signal.rb', line 11

def broadcast_create
  broadcast! if can_broadcast?

  broadcast_prepend_to(:signals, target: Signum.config.balloon_notifications_container_id.call,
                                 html: ApplicationController.render(Signum::Notification::Component.new(self)))

  broadcast_prepend_to(:signals, target: Signum.config.drawer_notifications_container_id.call,
                                 html: ApplicationController.render(Signum::NotificationDrawerItem::Component.new(signal: self)))
end

#broadcast_updateObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/signum/signal.rb', line 21

def broadcast_update
  return if saved_change_to_state? && (broadcasted? || shown?)

  if saved_change_to_state? && closed?
    broadcast_remove_to(:signals, target: "notification_drawer_item_parent_#{signalable_id}_#{id}")
    return
  end

  broadcast_replace_to(:signals, target: "notification_balloon_#{signalable_id}_#{id}",
                                 html: ApplicationController.render(Signum::NotificationBody::Component.new(self, { type: :balloon, timeout: 5 })))
  broadcast_replace_to(:signals, target: "notification_drawer_item_#{signalable_id}_#{id}",
                                 html: ApplicationController.render(Signum::NotificationBody::Component.new(self, { type: :drawer_item, timeout: 5 })))
end