1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

refactor: remove model.UserSessions struct

This commit is contained in:
Julien Voisin 2025-09-08 20:56:43 +02:00 committed by GitHub
parent 84078c7c20
commit f2976bff5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 13 deletions

View file

@ -28,13 +28,3 @@ func (u *UserSession) String() string {
func (u *UserSession) UseTimezone(tz string) {
u.CreatedAt = timezone.Convert(tz, u.CreatedAt)
}
// UserSessions represents a list of sessions.
type UserSessions []UserSession
// UseTimezone converts creation date of all sessions to the given timezone.
func (u UserSessions) UseTimezone(tz string) {
for _, session := range u {
session.UseTimezone(tz)
}
}

View file

@ -13,7 +13,7 @@ import (
)
// UserSessions returns the list of sessions for the given user.
func (s *Storage) UserSessions(userID int64) (model.UserSessions, error) {
func (s *Storage) UserSessions(userID int64) ([]model.UserSession, error) {
query := `
SELECT
id,
@ -33,7 +33,7 @@ func (s *Storage) UserSessions(userID int64) (model.UserSessions, error) {
}
defer rows.Close()
var sessions model.UserSessions
var sessions []model.UserSession
for rows.Next() {
var session model.UserSession
err := rows.Scan(

View file

@ -25,7 +25,9 @@ func (h *handler) showSessionsPage(w http.ResponseWriter, r *http.Request) {
return
}
sessions.UseTimezone(user.Timezone)
for _, sess := range sessions {
sess.UseTimezone(user.Timezone)
}
sess := session.New(h.store, request.SessionID(r))
view := view.New(h.tpl, r, sess)