Broadcast new notifications
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
module NotificationsHelper
|
||||
def notification_tray_tag
|
||||
tag.div id: "notification-tray", class: "notification-tray", data: { turbo_permanent: true } do
|
||||
turbo_frame_tag "notifications", src: notifications_path
|
||||
end
|
||||
def notification_tray
|
||||
notification_stream_tag + notification_tray_tag
|
||||
end
|
||||
|
||||
private
|
||||
def notification_stream_tag
|
||||
turbo_stream_from Current.user, :notifications
|
||||
end
|
||||
|
||||
def notification_tray_tag
|
||||
tag.div id: "notification-tray", class: "notification-tray", data: { turbo_permanent: true } do
|
||||
turbo_frame_tag("notifications", src: notifications_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,4 +5,6 @@ class Notification < ApplicationRecord
|
||||
|
||||
scope :unread, -> { where(read: false) }
|
||||
scope :ordered, -> { order(read: :desc, created_at: :desc) }
|
||||
|
||||
broadcasts_to ->(notification) { [ notification.user, :notifications ] }, inserts_by: :prepend
|
||||
end
|
||||
|
||||
@@ -51,4 +51,4 @@
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<%= notification_tray_tag %>
|
||||
<%= notification_tray %>
|
||||
|
||||
@@ -77,4 +77,4 @@
|
||||
<%= turbo_frame_tag dom_id(@bubble, :stage_picker), src: new_bucket_bubble_stage_picker_path(@bubble.bucket, @bubble) %>
|
||||
</div>
|
||||
|
||||
<%= notification_tray_tag %>
|
||||
<%= notification_tray %>
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
<%= render @filters %>
|
||||
</div>
|
||||
|
||||
<%= notification_tray_tag %>
|
||||
<%= notification_tray %>
|
||||
|
||||
Reference in New Issue
Block a user