improve song title editing

This commit is contained in:
2026-03-03 01:31:52 -08:00
parent f7baf2ee40
commit ace5205724
3 changed files with 20 additions and 12 deletions

View File

@@ -451,6 +451,12 @@ func UpdateSong(id int, title string, durationMs int, spotifyId, musicbrainzId s
_, err := Pool.Exec(context.Background(), _, err := Pool.Exec(context.Background(),
`UPDATE songs SET title = $1, duration_ms = $2, spotify_id = $3, musicbrainz_id = $4 WHERE id = $5`, `UPDATE songs SET title = $1, duration_ms = $2, spotify_id = $3, musicbrainz_id = $4 WHERE id = $5`,
title, durationMs, spotifyId, musicbrainzId, id) title, durationMs, spotifyId, musicbrainzId, id)
if err != nil {
return err
}
_, err = Pool.Exec(context.Background(),
`UPDATE history SET song_name = $1 WHERE song_id = $2`,
title, id)
return err return err
} }

View File

@@ -169,18 +169,13 @@ document.addEventListener('DOMContentLoaded', function() {
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
if (xhr.status === 200) { if (xhr.status === 200) {
// Update bio display if it exists var response = JSON.parse(xhr.responseText);
var bioDisplay = document.getElementById('bio-display'); if (response.success && entityType === 'song' && response.artist && response.title && response.username) {
if (bioDisplay && data.bio !== undefined) { var newUrl = '/profile/' + response.username + '/song/' + encodeURIComponent(response.artist) + '/' + encodeURIComponent(response.title);
bioDisplay.textContent = data.bio; window.location.href = newUrl;
} } else {
// Update info display if it exists
var infoDisplay = document.getElementById('info-display');
if (infoDisplay && data.title !== undefined) {
// Will be reloaded anyway, but close modal first
}
closeEditModal();
location.reload(); location.reload();
}
} else { } else {
alert('Error saving: ' + xhr.responseText); alert('Error saving: ' + xhr.responseText);
} }

View File

@@ -735,8 +735,15 @@ func songBatchEditHandler() http.HandlerFunc {
return return
} }
artist, _ := db.GetArtistById(song.ArtistId)
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"success": "true"}) json.NewEncoder(w).Encode(map[string]string{
"success": "true",
"artist": artist.Name,
"title": title,
"username": username,
})
} }
} }