Update inbox/notification counters when paginating
This commit is contained in:
parent
2c3e156dca
commit
a6f526b9c4
|
@ -1,3 +1,5 @@
|
|||
- inbox_count = current_user.unread_inbox_count
|
||||
|
||||
= turbo_stream.append "entries" do
|
||||
- @inbox.each do |i|
|
||||
= render "inbox/entry", i:
|
||||
|
@ -10,3 +12,13 @@
|
|||
params: { last_id: @inbox_last_id, author: @author }.compact,
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
= turbo_stream.update "nav-inbox-desktop" do
|
||||
= nav_entry t("navigation.inbox"), "/inbox",
|
||||
badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } },
|
||||
icon: "inbox", hotkey: "g i"
|
||||
|
||||
= turbo_stream.update "nav-inbox-mobile" do
|
||||
= nav_entry t("navigation.inbox"), "/inbox",
|
||||
badge: inbox_count, badge_color: "primary", badge_pill: true,
|
||||
icon: "inbox", icon_only: true
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
DEV
|
||||
%ul.nav.navbar-nav.me-auto
|
||||
= nav_entry t("navigation.timeline"), root_path, icon: "home", hotkey: "g t"
|
||||
#nav-inbox-desktop
|
||||
= nav_entry t("navigation.inbox"), "/inbox", icon: "inbox", badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } }, hotkey: "g i"
|
||||
- if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod?
|
||||
= nav_entry t("navigation.discover"), discover_path, icon: "compass", hotkey: "g d"
|
||||
|
@ -23,12 +24,7 @@
|
|||
%li.nav-item.dropdown.d-none.d-sm-block
|
||||
%a.nav-link.dropdown-toggle{ href: '#', data: { bs_toggle: :dropdown } }
|
||||
%turbo-frame#notification-desktop-icon
|
||||
- if notification_count.nil?
|
||||
%i.fa.fa-bell-o
|
||||
- else
|
||||
%i.fa.fa-bell
|
||||
%span.visually-hidden= t("navigation.notifications")
|
||||
%span.badge= notification_count
|
||||
= render "navigation/icons/notifications", notification_count:
|
||||
.dropdown-menu.dropdown-menu-end.notification-dropdown
|
||||
%turbo-frame#notifications-dropdown-list
|
||||
- cache current_user.notification_dropdown_cache_key do
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
.container
|
||||
%ul.nav.navbar-nav.navbar-icon-row
|
||||
= nav_entry t("navigation.timeline"), root_path, icon: 'home', icon_only: true
|
||||
#nav-inbox-mobile
|
||||
= nav_entry t("navigation.inbox"), '/inbox',
|
||||
badge: inbox_count, badge_color: 'primary', badge_pill: true,
|
||||
icon: 'inbox', icon_only: true
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
- if notification_count.nil?
|
||||
%i.fa.fa-bell-o
|
||||
- else
|
||||
%i.fa.fa-bell
|
||||
%span.visually-hidden= t("navigation.notifications")
|
||||
%span.badge= notification_count
|
|
@ -13,3 +13,6 @@
|
|||
params: { last_id: @notifications_last_id },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
= turbo_stream.update "notification-desktop-icon" do
|
||||
= render "navigation/icons/notifications", notification_count: current_user.unread_notification_count
|
||||
|
|
Loading…
Reference in New Issue