include unread count in tooltip
This commit is contained in:
parent
09a8e2ae67
commit
93af2ec84e
4 changed files with 7 additions and 16 deletions
|
@ -38,18 +38,9 @@ module ApplicationHelper
|
||||||
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
|
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_has_unread_notifications?
|
|
||||||
return @user_has_unread_notifications unless @user_has_unread_notifications.nil?
|
|
||||||
return (@user_has_unread_notifications = false) if current_user.nil?
|
|
||||||
current_user.mailboxer_notification_receipts.each do |receipt|
|
|
||||||
return (@user_has_unread_notifications = true) if receipt.is_read == false
|
|
||||||
end
|
|
||||||
@user_has_unread_notifications = false
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_unread_notification_count
|
def user_unread_notification_count
|
||||||
return 0 if current_user.nil?
|
return 0 if current_user.nil?
|
||||||
current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt|
|
@user_unread_notification_count ||= current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt|
|
||||||
receipt.is_read ? total : total + 1
|
receipt.is_read ? total : total + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<%= yield(:mobile_title) %>
|
<%= yield(:mobile_title) %>
|
||||||
</div>
|
</div>
|
||||||
<div id="menu_icon">
|
<div id="menu_icon">
|
||||||
<% if user_has_unread_notifications? %>
|
<% if user_unread_notification_count > 0 %>
|
||||||
<div class="unread-notifications-dot"></div>
|
<div class="unread-notifications-dot"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li class="notifications">
|
<li class="notifications">
|
||||||
<%= link_to "Notifications", notifications_path %>
|
<%= link_to "Notifications", notifications_path %>
|
||||||
<% if user_has_unread_notifications? %>
|
<% if user_unread_notification_count > 0 %>
|
||||||
<div class="unread-notifications-dot"></div>
|
<div class="unread-notifications-dot"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -76,11 +76,11 @@
|
||||||
</script>
|
</script>
|
||||||
<% if current_user.present? %>
|
<% if current_user.present? %>
|
||||||
<span id="notification_icon">
|
<span id="notification_icon">
|
||||||
<%= link_to notifications_path, class: "notificationsIcon upperRightEl upperRightIcon #{user_has_unread_notifications? ? 'unread' : 'read'}" do %>
|
<%= link_to notifications_path, class: "notificationsIcon upperRightEl upperRightIcon #{user_unread_notification_count > 0 ? 'unread' : 'read'}" do %>
|
||||||
<div class="tooltipsUnder">
|
<div class="tooltipsUnder">
|
||||||
Notifications
|
Notifications (<%= user_unread_notification_count %> unread)
|
||||||
</div>
|
</div>
|
||||||
<% if user_has_unread_notifications? %>
|
<% if user_unread_notification_count > 0 %>
|
||||||
<div class="unread-notifications-dot"></div>
|
<div class="unread-notifications-dot"></div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -20,7 +20,7 @@ class NotificationIcon extends Component {
|
||||||
return (
|
return (
|
||||||
<a className={linkClasses} href="/notifications">
|
<a className={linkClasses} href="/notifications">
|
||||||
<div className="tooltipsUnder">
|
<div className="tooltipsUnder">
|
||||||
Notifications
|
Notifications ({this.props.unreadNotificationsCount} unread)
|
||||||
</div>
|
</div>
|
||||||
{this.props.unreadNotificationsCount === 0 ? null : (
|
{this.props.unreadNotificationsCount === 0 ? null : (
|
||||||
<div className="unread-notifications-dot"></div>
|
<div className="unread-notifications-dot"></div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue