Some eventables are comments so we need to get to card.closed? via a different method

This commit is contained in:
Jason Zimdars
2025-05-21 14:07:25 -05:00
parent 92b4746edb
commit ccc83a9916
+6 -1
View File
@@ -22,7 +22,7 @@ module NotificationsHelper
tag.div id: dom_id(notification), class: "tray__item" do
concat(
link_to(notification,
class: [ "card card--notification", { "card--closed": notification.notifiable_target.closed? } ],
class: [ "card card--notification", { "card--closed": notification_closed?(notification) } ],
data: { action: "click->dialog#close", turbo_frame: "_top" },
&)
)
@@ -63,4 +63,9 @@ module NotificationsHelper
def card_notification_title(card)
card.title.presence || "Card #{card.id}"
end
def notification_closed?(notification)
eventable = notification.source.eventable
eventable.respond_to?(:card) ? eventable.card.closed? : eventable.closed?
end
end