6b229424a3
After talking to the mobile team we cam to the conclusion that for the API and the mobile apps speed is of the utmost importance when working with notifications. So we agreed to lower the unread notifications limit to 100 like we have in Basecamp. This strikes a balance between speed and usability.
21 lines
673 B
Ruby
21 lines
673 B
Ruby
class NotificationsController < ApplicationController
|
|
MAX_UNREAD_NOTIFICATIONS = 500
|
|
MAX_UNREAD_NOTIFICATIONS_VIA_API = 100
|
|
|
|
def index
|
|
@unread = Current.user.notifications.unread.ordered.preloaded.limit(max_unread_notifications) unless current_page_param
|
|
set_page_and_extract_portion_from Current.user.notifications.read.ordered.preloaded
|
|
|
|
respond_to do |format|
|
|
format.turbo_stream if current_page_param # Allows read-all action to side step pagination
|
|
format.html
|
|
format.json
|
|
end
|
|
end
|
|
|
|
private
|
|
def max_unread_notifications
|
|
request.format.json? ? MAX_UNREAD_NOTIFICATIONS_VIA_API : MAX_UNREAD_NOTIFICATIONS
|
|
end
|
|
end
|