feat(quick-5): add CreatedAt/UpdatedAt to playlist Summary struct

- Add CreatedAt and UpdatedAt string fields to Summary struct
- Format as RFC3339 at all construction sites in playlist.go and favorites.go
- Update TypeScript bindings with new fields in models.ts
This commit is contained in:
2026-03-01 08:51:00 -05:00
parent ea3648f3f8
commit bdaff478e8
3 changed files with 51 additions and 13 deletions
+11 -2
View File
@@ -3,6 +3,7 @@ package playlist
import ( import (
"errors" "errors"
"fmt" "fmt"
"time"
"yellowjacket/backend/database/sql/sqlcgen" "yellowjacket/backend/database/sql/sqlcgen"
"yellowjacket/backend/events" "yellowjacket/backend/events"
@@ -82,7 +83,10 @@ func (s *Service) EnsureDefaultPlaylist() {
) )
s.emitEvent(events.PlaylistCreated, Summary{ s.emitEvent(events.PlaylistCreated, Summary{
ID: created.ID, Name: created.Name, ID: created.ID,
Name: created.Name,
CreatedAt: created.CreatedAt.Format(time.RFC3339),
UpdatedAt: created.UpdatedAt.Format(time.RFC3339),
}) })
} }
@@ -138,7 +142,12 @@ func (s *Service) GetDefaultPlaylistInfo() (
) )
} }
return Summary{ID: pl.ID, Name: pl.Name}, nil return Summary{
ID: pl.ID,
Name: pl.Name,
CreatedAt: pl.CreatedAt.Format(time.RFC3339),
UpdatedAt: pl.UpdatedAt.Format(time.RFC3339),
}, nil
} }
// ToggleDefaultPlaylistTrack adds or removes a single track // ToggleDefaultPlaylistTrack adds or removes a single track
+31 -6
View File
@@ -12,6 +12,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
@@ -44,6 +45,8 @@ type LibraryDirProvider interface {
type Summary struct { type Summary struct {
ID int64 `json:"ID"` ID int64 `json:"ID"`
Name string `json:"Name"` Name string `json:"Name"`
CreatedAt string `json:"CreatedAt"`
UpdatedAt string `json:"UpdatedAt"`
} }
// Track represents a track within a playlist, including its // Track represents a track within a playlist, including its
@@ -162,6 +165,8 @@ func (s *Service) GetAllPlaylists() ([]Summary, error) {
summaries = append(summaries, Summary{ summaries = append(summaries, Summary{
ID: p.ID, ID: p.ID,
Name: p.Name, Name: p.Name,
CreatedAt: p.CreatedAt.Format(time.RFC3339),
UpdatedAt: p.UpdatedAt.Format(time.RFC3339),
}) })
} }
@@ -236,7 +241,12 @@ func (s *Service) GetAllPlaylistsWithTracks() (
) )
result = append(result, WithTracks{ result = append(result, WithTracks{
Summary: Summary{ID: p.ID, Name: p.Name}, Summary: Summary{
ID: p.ID,
Name: p.Name,
CreatedAt: p.CreatedAt.Format(time.RFC3339),
UpdatedAt: p.UpdatedAt.Format(time.RFC3339),
},
Tracks: tracks, Tracks: tracks,
}) })
} }
@@ -439,11 +449,17 @@ func (s *Service) CreatePlaylist(
s.savePlaylistFile(created.ID, created.Name) s.savePlaylistFile(created.ID, created.Name)
s.emitEvent(events.PlaylistCreated, Summary{ s.emitEvent(events.PlaylistCreated, Summary{
ID: created.ID, Name: created.Name, ID: created.ID,
Name: created.Name,
CreatedAt: created.CreatedAt.Format(time.RFC3339),
UpdatedAt: created.UpdatedAt.Format(time.RFC3339),
}) })
return Summary{ return Summary{
ID: created.ID, Name: created.Name, ID: created.ID,
Name: created.Name,
CreatedAt: created.CreatedAt.Format(time.RFC3339),
UpdatedAt: created.UpdatedAt.Format(time.RFC3339),
}, nil }, nil
} }
@@ -543,7 +559,10 @@ func (s *Service) CreatePlaylistWithTracks(
} }
summary := Summary{ summary := Summary{
ID: created.ID, Name: created.Name, ID: created.ID,
Name: created.Name,
CreatedAt: created.CreatedAt.Format(time.RFC3339),
UpdatedAt: created.UpdatedAt.Format(time.RFC3339),
} }
s.logger.Info( s.logger.Info(
@@ -675,7 +694,8 @@ func (s *Service) RenamePlaylist(
) )
s.emitEvent(events.PlaylistRenamed, Summary{ s.emitEvent(events.PlaylistRenamed, Summary{
ID: playlistID, Name: trimmed, ID: playlistID,
Name: trimmed,
}) })
return nil return nil
@@ -689,8 +709,10 @@ func (s *Service) uniquePlaylistName(name string) string {
if err != nil || count == 0 { if err != nil || count == 0 {
return name return name
} }
for i := 1; ; i++ { for i := 1; ; i++ {
candidate := fmt.Sprintf("%s (%d)", name, i) candidate := fmt.Sprintf("%s (%d)", name, i)
c, err := s.db.Queries.CountPlaylistsByName(s.db.Ctx, candidate) c, err := s.db.Queries.CountPlaylistsByName(s.db.Ctx, candidate)
if err != nil || c == 0 { if err != nil || c == 0 {
return candidate return candidate
@@ -804,7 +826,10 @@ func (s *Service) ImportPlaylist(
) )
summary := Summary{ summary := Summary{
ID: created.ID, Name: playlistName, ID: created.ID,
Name: playlistName,
CreatedAt: created.CreatedAt.Format(time.RFC3339),
UpdatedAt: created.UpdatedAt.Format(time.RFC3339),
} }
s.emitEvent(events.PlaylistCreated, summary) s.emitEvent(events.PlaylistCreated, summary)
+4
View File
@@ -305,6 +305,8 @@ export namespace playlist {
export class Summary { export class Summary {
ID: number; ID: number;
Name: string; Name: string;
CreatedAt: string;
UpdatedAt: string;
static createFrom(source: any = {}) { static createFrom(source: any = {}) {
return new Summary(source); return new Summary(source);
@@ -314,6 +316,8 @@ export namespace playlist {
if ('string' === typeof source) source = JSON.parse(source); if ('string' === typeof source) source = JSON.parse(source);
this.ID = source["ID"]; this.ID = source["ID"];
this.Name = source["Name"]; this.Name = source["Name"];
this.CreatedAt = source["CreatedAt"];
this.UpdatedAt = source["UpdatedAt"];
} }
} }
export class Track { export class Track {