mirror of
https://github.com/riwiwa/muzi.git
synced 2026-03-04 00:51:59 -08:00
improve song title editing
This commit is contained in:
@@ -451,6 +451,12 @@ func UpdateSong(id int, title string, durationMs int, spotifyId, musicbrainzId s
|
||||
_, err := Pool.Exec(context.Background(),
|
||||
`UPDATE songs SET title = $1, duration_ms = $2, spotify_id = $3, musicbrainz_id = $4 WHERE id = $5`,
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -169,18 +169,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
// Update bio display if it exists
|
||||
var bioDisplay = document.getElementById('bio-display');
|
||||
if (bioDisplay && data.bio !== undefined) {
|
||||
bioDisplay.textContent = data.bio;
|
||||
}
|
||||
// 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();
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
if (response.success && entityType === 'song' && response.artist && response.title && response.username) {
|
||||
var newUrl = '/profile/' + response.username + '/song/' + encodeURIComponent(response.artist) + '/' + encodeURIComponent(response.title);
|
||||
window.location.href = newUrl;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
alert('Error saving: ' + xhr.responseText);
|
||||
}
|
||||
|
||||
@@ -735,8 +735,15 @@ func songBatchEditHandler() http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
artist, _ := db.GetArtistById(song.ArtistId)
|
||||
|
||||
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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user