From cd1895e3c465ca76df392012123cf1aa61d76681 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 24 Mar 2018 20:28:27 +0100 Subject: [PATCH] Increased max notifications --- pages/notifications/all.go | 33 ++++++++++++++++++++++++++++ pages/notifications/notifications.go | 21 ------------------ 2 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 pages/notifications/all.go diff --git a/pages/notifications/all.go b/pages/notifications/all.go new file mode 100644 index 00000000..e8d781e7 --- /dev/null +++ b/pages/notifications/all.go @@ -0,0 +1,33 @@ +package notifications + +import ( + "net/http" + "sort" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +const maxAllNotifications = 150 + +// All shows all notifications. +func All(ctx *aero.Context) string { + notifications, err := arn.AllNotifications() + + if err != nil { + return ctx.Error(http.StatusInternalServerError, "Could not retrieve notification list", err) + } + + // Sort by date + sort.Slice(notifications, func(i, j int) bool { + return notifications[i].Created > notifications[j].Created + }) + + // Limit results + if len(notifications) > maxAllNotifications { + notifications = notifications[:maxAllNotifications] + } + + return ctx.HTML(components.AllNotifications(notifications)) +} diff --git a/pages/notifications/notifications.go b/pages/notifications/notifications.go index 158d193a..58cd72f5 100644 --- a/pages/notifications/notifications.go +++ b/pages/notifications/notifications.go @@ -44,24 +44,3 @@ func ByUser(ctx *aero.Context) string { return ctx.HTML(components.Notifications(notifications, viewUser, user)) } - -// All shows all notifications. -func All(ctx *aero.Context) string { - notifications, err := arn.AllNotifications() - - if err != nil { - return ctx.Error(http.StatusInternalServerError, "Could not retrieve notification list", err) - } - - // Sort by date - sort.Slice(notifications, func(i, j int) bool { - return notifications[i].Created > notifications[j].Created - }) - - // Limit results - if len(notifications) > maxNotifications { - notifications = notifications[:maxNotifications] - } - - return ctx.HTML(components.AllNotifications(notifications)) -}