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:
Ahmed Gagan
2020-07-02 15:36:00 +05:30
committed by GitHub
parent 95153356ea
commit 04d7693355
9 changed files with 76 additions and 29 deletions

View File

@ -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