frontend fixes
album artist gets populated with artist as fallback (frontend also uses this as display name fallback for albums). added scroll position persistence when switching main views. also added frontend cache for faster switching.
This commit is contained in:
@@ -43,13 +43,20 @@ SELECT * FROM release_groups
|
||||
ORDER BY name;
|
||||
|
||||
-- name: GetAllAlbumsWithDetails :many
|
||||
SELECT
|
||||
SELECT
|
||||
rg.id,
|
||||
rg.name,
|
||||
rg.year,
|
||||
COALESCE(ac.text, '') as artist_name,
|
||||
COALESCE(ac.text, fallback_ac.text, '') as artist_name,
|
||||
COALESCE(ca.file_path, '') as cover_art_path
|
||||
FROM release_groups rg
|
||||
LEFT JOIN artist_credit ac ON rg.album_artist_credit_id = ac.id
|
||||
LEFT JOIN cover_art ca ON rg.cover_art_id = ca.id
|
||||
LEFT JOIN (
|
||||
SELECT rgr.release_group_id, ac2.text
|
||||
FROM release_group_recordings rgr
|
||||
JOIN recordings rec ON rec.id = rgr.recording_id
|
||||
JOIN artist_credit ac2 ON ac2.id = rec.artist_credit_id
|
||||
GROUP BY rgr.release_group_id
|
||||
) fallback_ac ON fallback_ac.release_group_id = rg.id
|
||||
ORDER BY rg.name;
|
||||
|
||||
@@ -79,15 +79,22 @@ func (q *Queries) DeleteReleaseGroup(ctx context.Context, id int64) error {
|
||||
}
|
||||
|
||||
const getAllAlbumsWithDetails = `-- name: GetAllAlbumsWithDetails :many
|
||||
SELECT
|
||||
SELECT
|
||||
rg.id,
|
||||
rg.name,
|
||||
rg.year,
|
||||
COALESCE(ac.text, '') as artist_name,
|
||||
COALESCE(ac.text, fallback_ac.text, '') as artist_name,
|
||||
COALESCE(ca.file_path, '') as cover_art_path
|
||||
FROM release_groups rg
|
||||
LEFT JOIN artist_credit ac ON rg.album_artist_credit_id = ac.id
|
||||
LEFT JOIN cover_art ca ON rg.cover_art_id = ca.id
|
||||
LEFT JOIN (
|
||||
SELECT rgr.release_group_id, ac2.text
|
||||
FROM release_group_recordings rgr
|
||||
JOIN recordings rec ON rec.id = rgr.recording_id
|
||||
JOIN artist_credit ac2 ON ac2.id = rec.artist_credit_id
|
||||
GROUP BY rgr.release_group_id
|
||||
) fallback_ac ON fallback_ac.release_group_id = rg.id
|
||||
ORDER BY rg.name
|
||||
`
|
||||
|
||||
|
||||
@@ -49,3 +49,8 @@ const (
|
||||
const (
|
||||
LibraryConfigChanged = "LibraryConfigChanged"
|
||||
)
|
||||
|
||||
// Library events.
|
||||
const (
|
||||
LibraryScanComplete = "LibraryScanComplete"
|
||||
)
|
||||
|
||||
@@ -335,6 +335,8 @@ func (l *Library) Scan() error {
|
||||
"library", l.conf.DirectoryPath,
|
||||
)
|
||||
|
||||
runtime.EventsEmit(l.ctx, events.LibraryScanComplete)
|
||||
|
||||
return scanErr
|
||||
}
|
||||
|
||||
@@ -510,18 +512,27 @@ func (l *Library) processMetadata(result importResult) (int64, error) {
|
||||
})
|
||||
}
|
||||
|
||||
// 3. Get or create artist credit for album artist (if different)
|
||||
// 3. Get or create artist credit for album artist.
|
||||
// Always assign an album artist credit so the cover grid displays an
|
||||
// artist name. When the AlbumArtist tag is absent or identical to the
|
||||
// track Artist, reuse the track artist credit instead of leaving it NULL.
|
||||
var albumArtistCreditID sql.NullInt64
|
||||
|
||||
if tags.AlbumArtist != "" && tags.AlbumArtist != tags.Artist {
|
||||
albumArtistCredit, err := l.db.Queries.UpsertArtistCredit(l.ctx, tags.AlbumArtist)
|
||||
albumArtistCredit, err := l.db.Queries.UpsertArtistCredit(
|
||||
l.ctx, tags.AlbumArtist,
|
||||
)
|
||||
if err != nil {
|
||||
l.logger.Warn("could not upsert album artist credit", "err", err)
|
||||
} else {
|
||||
albumArtistCreditID = sql.NullInt64{Int64: albumArtistCredit.ID, Valid: true}
|
||||
albumArtistCreditID = sql.NullInt64{
|
||||
Int64: albumArtistCredit.ID, Valid: true,
|
||||
}
|
||||
|
||||
// Also create the artist record and link
|
||||
albumArtist, err := l.db.Queries.UpsertArtist(l.ctx, tags.AlbumArtist)
|
||||
// Also create the artist record and link.
|
||||
albumArtist, err := l.db.Queries.UpsertArtist(
|
||||
l.ctx, tags.AlbumArtist,
|
||||
)
|
||||
if err != nil {
|
||||
l.logger.Warn("could not upsert album artist", "err", err)
|
||||
} else {
|
||||
@@ -534,6 +545,12 @@ func (l *Library) processMetadata(result importResult) (int64, error) {
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// AlbumArtist is empty or matches the track artist — reuse the
|
||||
// track artist credit so the release group always has an artist.
|
||||
albumArtistCreditID = sql.NullInt64{
|
||||
Int64: artistCredit.ID, Valid: true,
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Get or create release group (album)
|
||||
|
||||
Reference in New Issue
Block a user