Increased max notifications
This commit is contained in:
parent
504d42fb52
commit
cd1895e3c4
33
pages/notifications/all.go
Normal file
33
pages/notifications/all.go
Normal file
@ -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))
|
||||||
|
}
|
@ -44,24 +44,3 @@ func ByUser(ctx *aero.Context) string {
|
|||||||
|
|
||||||
return ctx.HTML(components.Notifications(notifications, viewUser, user))
|
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))
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user