From 38bd282b381dbc840f18947fe4481a409473c26f Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 8 Aug 2021 00:13:12 +0200 Subject: [PATCH] Make notification icon show notification count badge --- app/views/navigation/_mobile.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/navigation/_mobile.haml b/app/views/navigation/_mobile.haml index 59d8b7fd..715f5e8b 100644 --- a/app/views/navigation/_mobile.haml +++ b/app/views/navigation/_mobile.haml @@ -1,4 +1,8 @@ = render 'navigation/mobile/profile' +:ruby + notification_count = Notification.for(current_user).where(new: true).count + notification_count = nil if notification_count.zero? + notifications_icon = notification_count.nil? ? 'bell-o' : 'bell' %nav.navbar.navbar-themed.bg-primary.fixed-bottom.d-lg-none.d-block#rs-mobile-nav{ role: :navigation } .container{ class: ios_web_app? ? 'ios-web-app' : '' } %ul.nav.navbar-nav.navbar-icon-row @@ -6,7 +10,7 @@ = nav_entry t('views.navigation.inbox'), '/inbox', badge: inbox_count, icon: 'inbox', icon_only: true - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t('views.navigation.discover'), discover_path, icon: 'compass', icon_only: true - = nav_entry t('views.navigation.notifications'), '#', icon: 'bell-o', icon_only: true + = nav_entry t('views.navigation.notifications'), '/notifications', badge: notification_count, icon: notifications_icon, icon_only: true %li.nav-item.profile--image-dropdown %a.nav-link{ href: '#', data: { toggle: 'dropdown', target: '#rs-mobile-nav-profile' }, aria: { controls: 'rs-mobile-nav-profile', expanded: 'false' } } %img.avatar-md.d-inline{ src: current_user.profile_picture.url(:small) }