mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:00:46 +08:00
FIX: Filter read/unread notifications on the server side (#10152)
https://meta.discourse.org/t/notifications-unread-only-filter/37621/32
This commit is contained in:
@ -44,12 +44,16 @@ class NotificationsController < ApplicationController
|
||||
.includes(:topic)
|
||||
.order(created_at: :desc)
|
||||
|
||||
notifications = notifications.where(read: true) if params[:filter] == "read"
|
||||
|
||||
notifications = notifications.where(read: false) if params[:filter] == "unread"
|
||||
|
||||
total_rows = notifications.dup.count
|
||||
notifications = notifications.offset(offset).limit(60)
|
||||
render_json_dump(notifications: serialize_data(notifications, NotificationSerializer),
|
||||
total_rows_notifications: total_rows,
|
||||
seen_notification_id: user.seen_notification_id,
|
||||
load_more_notifications: notifications_path(username: user.username, offset: offset + 60))
|
||||
load_more_notifications: notifications_path(username: user.username, offset: offset + 60, filter: params[:filter]))
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user