Class: Collavre::Inbox::BadgeComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Collavre::Inbox::BadgeComponent
- Defined in:
- app/components/collavre/inbox/badge_component.rb
Instance Attribute Summary collapse
-
#badge_id ⇒ Object
readonly
Returns the value of attribute badge_id.
-
#show_zero ⇒ Object
readonly
Returns the value of attribute show_zero.
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(user: nil, creative: nil, count: nil, badge_id: "desktop-inbox-badge", show_zero: false) ⇒ BadgeComponent
constructor
A new instance of BadgeComponent.
Constructor Details
#initialize(user: nil, creative: nil, count: nil, badge_id: "desktop-inbox-badge", show_zero: false) ⇒ BadgeComponent
Returns a new instance of BadgeComponent.
6 7 8 9 10 11 12 |
# File 'app/components/collavre/inbox/badge_component.rb', line 6 def initialize(user: nil, creative: nil, count: nil, badge_id: "desktop-inbox-badge", show_zero: false) @user = user @creative = creative @count = count @badge_id = badge_id @show_zero = show_zero end |
Instance Attribute Details
#badge_id ⇒ Object (readonly)
Returns the value of attribute badge_id.
4 5 6 |
# File 'app/components/collavre/inbox/badge_component.rb', line 4 def badge_id @badge_id end |
#show_zero ⇒ Object (readonly)
Returns the value of attribute show_zero.
4 5 6 |
# File 'app/components/collavre/inbox/badge_component.rb', line 4 def show_zero @show_zero end |
Instance Method Details
#count ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/collavre/inbox/badge_component.rb', line 14 def count return @count if @count if @creative && @user # Use CommentReadPointer-based unread count for inbox creative unread_count_for_creative else # Legacy fallback: InboxItem count InboxItem.where(owner: @user, state: "new").count end end |