Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Update profile.go

Cette révision appartient à :
kilo 2017-10-29 19:30:16 +01:00 révisé par GitHub
Parent e60b2afa62
révision 7490e44a67
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: 4AEE18F83AFDEB23

Voir le fichier

@ -8,7 +8,6 @@ import (
"net/http" "net/http"
"github.com/NyaaPantsu/nyaa/controllers/router" "github.com/NyaaPantsu/nyaa/controllers/router"
"github.com/NyaaPantsu/nyaa/models"
"github.com/NyaaPantsu/nyaa/models/notifications" "github.com/NyaaPantsu/nyaa/models/notifications"
"github.com/NyaaPantsu/nyaa/models/users" "github.com/NyaaPantsu/nyaa/models/users"
"github.com/NyaaPantsu/nyaa/templates" "github.com/NyaaPantsu/nyaa/templates"
@ -218,20 +217,15 @@ func UserNotificationsHandler(c *gin.Context) {
if currentUser.ID > 0 { if currentUser.ID > 0 {
messages := msg.GetMessages(c) messages := msg.GetMessages(c)
if c.Request.URL.Query()["clear"] != nil { if c.Request.URL.Query()["clear"] != nil {
notifications.DeleteNotifications(currentUser.ID, false) notifications.DeleteNotifications(currentUser, false)
messages.AddInfoT("infos", "notifications_cleared") messages.AddInfoT("infos", "read_notifications_cleared")
NewNotifications := []models.Notification{}
for _, notif := range currentUser.Notifications {
if !notif.Read {
NewNotifications = append(NewNotifications, notif)
}
}
currentUser.Notifications = NewNotifications
} else if c.Request.URL.Query()["clear_all"] != nil { } else if c.Request.URL.Query()["clear_all"] != nil {
notifications.DeleteNotifications(currentUser.ID, true) notifications.DeleteNotifications(currentUser, true)
messages.AddInfoT("infos", "notifications_cleared") messages.AddInfoT("infos", "notifications_cleared")
currentUser.Notifications = []models.Notification{} } else if c.Request.URL.Query()["read_all"] != nil {
notifications.MarkAllNotificationsAsRead(currentUser)
messages.AddInfoT("infos", "notifications_read")
} }
templates.UserProfileNotifications(c, currentUser) templates.UserProfileNotifications(c, currentUser)
} else { } else {