From bdaff478e802ee5c0745327c52dd9b190fcfef7d Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Sun, 1 Mar 2026 08:51:00 -0500 Subject: [PATCH] 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 --- backend/playlist/favorites.go | 13 ++++++++-- backend/playlist/playlist.go | 47 +++++++++++++++++++++++++++-------- frontend/wailsjs/go/models.ts | 4 +++ 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/backend/playlist/favorites.go b/backend/playlist/favorites.go index 05cd51f..66c3a9b 100644 --- a/backend/playlist/favorites.go +++ b/backend/playlist/favorites.go @@ -3,6 +3,7 @@ package playlist import ( "errors" "fmt" + "time" "yellowjacket/backend/database/sql/sqlcgen" "yellowjacket/backend/events" @@ -82,7 +83,10 @@ func (s *Service) EnsureDefaultPlaylist() { ) 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 diff --git a/backend/playlist/playlist.go b/backend/playlist/playlist.go index 675e5fb..0b62333 100644 --- a/backend/playlist/playlist.go +++ b/backend/playlist/playlist.go @@ -12,6 +12,7 @@ import ( "strconv" "strings" "sync" + "time" "github.com/wailsapp/wails/v2/pkg/runtime" @@ -42,8 +43,10 @@ type LibraryDirProvider interface { // Summary is a lightweight representation of a playlist for the // picker UI. type Summary struct { - ID int64 `json:"ID"` - Name string `json:"Name"` + ID int64 `json:"ID"` + Name string `json:"Name"` + CreatedAt string `json:"CreatedAt"` + UpdatedAt string `json:"UpdatedAt"` } // Track represents a track within a playlist, including its @@ -160,8 +163,10 @@ func (s *Service) GetAllPlaylists() ([]Summary, error) { for _, p := range playlists { summaries = append(summaries, Summary{ - ID: p.ID, - Name: p.Name, + ID: p.ID, + Name: p.Name, + CreatedAt: p.CreatedAt.Format(time.RFC3339), + UpdatedAt: p.UpdatedAt.Format(time.RFC3339), }) } @@ -236,8 +241,13 @@ func (s *Service) GetAllPlaylistsWithTracks() ( ) result = append(result, WithTracks{ - Summary: Summary{ID: p.ID, Name: p.Name}, - Tracks: tracks, + Summary: Summary{ + ID: p.ID, + Name: p.Name, + CreatedAt: p.CreatedAt.Format(time.RFC3339), + UpdatedAt: p.UpdatedAt.Format(time.RFC3339), + }, + Tracks: tracks, }) } @@ -439,11 +449,17 @@ func (s *Service) CreatePlaylist( s.savePlaylistFile(created.ID, created.Name) 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{ - 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 } @@ -543,7 +559,10 @@ func (s *Service) CreatePlaylistWithTracks( } 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( @@ -675,7 +694,8 @@ func (s *Service) RenamePlaylist( ) s.emitEvent(events.PlaylistRenamed, Summary{ - ID: playlistID, Name: trimmed, + ID: playlistID, + Name: trimmed, }) return nil @@ -689,8 +709,10 @@ func (s *Service) uniquePlaylistName(name string) string { if err != nil || count == 0 { return name } + for i := 1; ; i++ { candidate := fmt.Sprintf("%s (%d)", name, i) + c, err := s.db.Queries.CountPlaylistsByName(s.db.Ctx, candidate) if err != nil || c == 0 { return candidate @@ -804,7 +826,10 @@ func (s *Service) ImportPlaylist( ) 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) diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index 53ff78d..b13eeed 100755 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -305,6 +305,8 @@ export namespace playlist { export class Summary { ID: number; Name: string; + CreatedAt: string; + UpdatedAt: string; static createFrom(source: any = {}) { return new Summary(source); @@ -314,6 +316,8 @@ export namespace playlist { if ('string' === typeof source) source = JSON.parse(source); this.ID = source["ID"]; this.Name = source["Name"]; + this.CreatedAt = source["CreatedAt"]; + this.UpdatedAt = source["UpdatedAt"]; } } export class Track {