mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-22 19:27:47 +01:00
Merge pull request #1195 from Retrospring/feature/cache-notifications-dropdown
Cache notifications dropdown
This commit is contained in:
commit
8483532605
3 changed files with 5 additions and 3 deletions
|
@ -14,4 +14,5 @@ module User::NotificationMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
def notification_cache_key = "#{cache_key}/unread_notification_count-#{notifications_updated_at}"
|
def notification_cache_key = "#{cache_key}/unread_notification_count-#{notifications_updated_at}"
|
||||||
|
def notification_dropdown_cache_key = "#{cache_key}/notification_dropdown-#{notifications_updated_at}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
%span.badge= notification_count
|
%span.badge= notification_count
|
||||||
.dropdown-menu.dropdown-menu-end.notification-dropdown
|
.dropdown-menu.dropdown-menu-end.notification-dropdown
|
||||||
%turbo-frame#notifications-dropdown-list
|
%turbo-frame#notifications-dropdown-list
|
||||||
= render "navigation/dropdown/notifications", notifications:, notification_count: nil
|
- Rails.cache.fetch current_user.notification_dropdown_cache_key do
|
||||||
|
- notifications = Notification.for(current_user).where(new: true).includes([:target]).limit(4)
|
||||||
|
= render "navigation/dropdown/notifications", notifications:, size: "desktop"
|
||||||
%li.nav-item.d-none.d-sm-block{ data: { bs_toggle: 'tooltip', bs_placement: 'bottom' }, title: t('.ask_question') }
|
%li.nav-item.d-none.d-sm-block{ data: { bs_toggle: 'tooltip', bs_placement: 'bottom' }, title: t('.ask_question') }
|
||||||
%a.nav-link{ href: "#", name: "toggle-all-ask", data: { bs_target: "#modal-ask-followers", bs_toggle: :modal, hotkey: "n" } }
|
%a.nav-link{ href: "#", name: "toggle-all-ask", data: { bs_target: "#modal-ask-followers", bs_toggle: :modal, hotkey: "n" } }
|
||||||
%i.fa.fa-pencil-square-o
|
%i.fa.fa-pencil-square-o
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
:ruby
|
:ruby
|
||||||
notifications = Notification.for(current_user).where(new: true).includes([:target]).limit(4)
|
|
||||||
inbox_count = current_user.unread_inbox_count
|
inbox_count = current_user.unread_inbox_count
|
||||||
notification_count = current_user.unread_notification_count
|
notification_count = current_user.unread_notification_count
|
||||||
= render "navigation/desktop", notifications:, inbox_count:, notification_count:
|
= render "navigation/desktop", inbox_count:, notification_count:
|
||||||
= render "navigation/mobile", inbox_count:, notification_count:
|
= render "navigation/mobile", inbox_count:, notification_count:
|
||||||
|
|
||||||
= render "modal/ask"
|
= render "modal/ask"
|
||||||
|
|
Loading…
Reference in a new issue