diff --git a/backend/queue/playhistory.go b/backend/queue/playhistory.go index 3351c58..cf5c23d 100644 --- a/backend/queue/playhistory.go +++ b/backend/queue/playhistory.go @@ -1,6 +1,12 @@ package queue -import "time" +import ( + "time" + + "github.com/wailsapp/wails/v2/pkg/runtime" + + "yellowjacket/backend/events" +) // recordPlay inserts a play_history row and updates the denormalized // play_count / last_played columns on audio_files. Called from @@ -54,4 +60,11 @@ func (q *Queue) recordPlay(audioFileID int64) { "Play recorded", "audioFileId", audioFileID, ) + + // Notify frontend so the track list refreshes play count. + if q.ctx != nil { + runtime.EventsEmit( + q.ctx, events.TrackMetadataChanged, + ) + } } diff --git a/frontend/src/components/track-list/columns.ts b/frontend/src/components/track-list/columns.ts index eeda875..c8005a8 100644 --- a/frontend/src/components/track-list/columns.ts +++ b/frontend/src/components/track-list/columns.ts @@ -190,7 +190,7 @@ export const COLUMN_DEFS: Record = { id: 'playCount', label: 'Play Count', accessor: (t) => - t.PlayCount ? String(t.PlayCount) : '', + String(t.PlayCount ?? 0), defaultWidth: '80px', align: 'right', comparator: (a, b) =>