Added additional route for notifications view
This commit is contained in:
parent
08b7a0e75c
commit
40ea58dffe
@ -162,6 +162,7 @@ func Configure(app *aero.Application) {
|
||||
l.Page("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
|
||||
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get)
|
||||
l.Page("/user/:nick/recommended/anime", recommended.Anime)
|
||||
l.Page("/user/:nick/notifications", notifications.All)
|
||||
|
||||
// Anime list
|
||||
l.Page("/animelist/watching", home.FilterByStatus(arn.AnimeListStatusWatching))
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
@ -19,7 +21,16 @@ func All(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusBadRequest, "Not logged in", nil)
|
||||
}
|
||||
|
||||
notifications := user.Notifications().Notifications()
|
||||
var viewUser *arn.User
|
||||
nick := ctx.Get("nick")
|
||||
|
||||
if nick != "" {
|
||||
viewUser, _ = arn.GetUserByNick(nick)
|
||||
} else {
|
||||
viewUser = user
|
||||
}
|
||||
|
||||
notifications := viewUser.Notifications().Notifications()
|
||||
|
||||
// Sort by date
|
||||
sort.Slice(notifications, func(i, j int) bool {
|
||||
@ -31,5 +42,5 @@ func All(ctx *aero.Context) string {
|
||||
notifications = notifications[:maxNotifications]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Notifications(notifications, user))
|
||||
return ctx.HTML(components.Notifications(notifications, viewUser, user))
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
component Notifications(notifications []*arn.Notification, user *arn.User)
|
||||
component Notifications(notifications []*arn.Notification, viewUser *arn.User, user *arn.User)
|
||||
h1 Notifications
|
||||
|
||||
.corner-buttons
|
||||
if user.ID == viewUser.ID
|
||||
button.action(data-action="markNotificationsAsSeen", data-trigger="click")
|
||||
Icon("check")
|
||||
span Mark all as seen
|
||||
|
1
tests.go
1
tests.go
@ -268,6 +268,7 @@ var routeTests = map[string][]string{
|
||||
"/import/kitsu/animelist": nil,
|
||||
"/import/kitsu/animelist/finish": nil,
|
||||
"/notifications": nil,
|
||||
"/user/:nick/notifications": nil,
|
||||
"/api/test/notification": nil,
|
||||
"/api/paypal/payment/create": nil,
|
||||
"/api/userfollows/:id/get/:item": nil,
|
||||
|
Loading…
Reference in New Issue
Block a user