Skip to content

Commit 847574f

Browse files
committed
Include read notifications in the tray API response
1 parent 93ed13f commit 847574f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
class Notifications::TraysController < ApplicationController
2+
MAX_ENTRIES_LIMIT = 100
3+
24
def show
3-
@notifications = Current.user.notifications.preloaded.unread.ordered.limit(100)
5+
@notifications = unread_notifications + read_notifications
46

57
# Invalidate on the whole set instead of the unread set since the max updated at in the unread set
68
# can stay the same when reading old notifications.
79
fresh_when Current.user.notifications
810
end
11+
12+
private
13+
def unread_notifications
14+
Current.user.notifications.preloaded.unread.ordered.limit(MAX_ENTRIES_LIMIT)
15+
end
16+
17+
def read_notifications
18+
Current.user.notifications.preloaded.read.ordered.limit(MAX_ENTRIES_LIMIT)
19+
end
920
end

0 commit comments

Comments
 (0)