From 884e95dc58ea7fc7127d0cbf61482106ad5182f9 Mon Sep 17 00:00:00 2001 From: krateng Date: Thu, 21 Apr 2022 18:04:01 +0200 Subject: [PATCH] Manual scrobbling now also uses new notification system --- maloja/web/static/js/manualscrobble.js | 3 ++- maloja/web/static/js/notifications.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/maloja/web/static/js/manualscrobble.js b/maloja/web/static/js/manualscrobble.js index 1ae55de..4a58ee9 100644 --- a/maloja/web/static/js/manualscrobble.js +++ b/maloja/web/static/js/manualscrobble.js @@ -69,8 +69,9 @@ function scrobble(artists,title) { "title":title } + if (title != "" && artists.length > 0) { - neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=scrobbledone,json=true) + neo.xhttpreq("/apis/mlj_1/newscrobble",data=payload,method="POST",callback=notifyCallback,json=true) } document.getElementById("title").value = ""; diff --git a/maloja/web/static/js/notifications.js b/maloja/web/static/js/notifications.js index 54ad153..43e656f 100644 --- a/maloja/web/static/js/notifications.js +++ b/maloja/web/static/js/notifications.js @@ -38,14 +38,17 @@ function notifyCallback(request) { var body = request.response; var status = request.status; - if (status == 200) { var notification_type = 'info'; + var title = "Success!"; + var msg = "Scrobbled " + body.track.title + " by " + body.track.artists.join(", "); } else { var notification_type = 'warning'; + var title = "Error: " + body.error.type; + var msg = body.error.desc || ""; } - notify("Error: " + body.error.type,body.error.desc || "",notification_type); + notify(title,msg,notification_type); }