mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
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:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user