DEV: Add messages tab to the new user menu (#17850)

Some of the changes in this PR are extracted from https://github.com/discourse/discourse/pull/17379.

Similar to the bookmarks tab in the new user menu, the messages tab also displays a mix of notifications and messages. When there are unread message notifications, the tab displays all of these notifications at the top and fills the remaining space in the menu with a list of the user's messages. The bubble/badge count on the messages tab indicates how many unread message notifications there are.
This commit is contained in:
Osama Sayegh
2022-08-10 08:25:39 +03:00
committed by GitHub
parent 23520b88c2
commit 473695ee4d
20 changed files with 811 additions and 90 deletions

View File

@ -15,6 +15,9 @@ class Notification < ActiveRecord::Base
scope :recent, lambda { |n = nil| n ||= 10; order('notifications.created_at desc').limit(n) }
scope :visible , lambda { joins('LEFT JOIN topics ON notifications.topic_id = topics.id')
.where('topics.id IS NULL OR topics.deleted_at IS NULL') }
scope :unread_type, ->(user, type, limit = 20) do
where(user_id: user.id, read: false, notification_type: type).visible.includes(:topic).limit(limit)
end
attr_accessor :skip_send_email