diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index a8a0855..a0d499b 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -708,7 +708,8 @@ def reparse_scrobble(timestamp): if result: return { "status":"success", - "desc":f"Scrobble was reparsed!" + "desc":f"Scrobble was reparsed!", + "scrobble":result } else: return { diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index e7100dc..473cb7b 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -118,7 +118,9 @@ def reparse_scrobble(timestamp): # check if id changed if sqldb.get_track_id(scrobble['track']) != track_id: sqldb.edit_scrobble(timestamp, {'track':newscrobble['track']}) - return True + dbcache.invalidate_entity_cache() + dbcache.invalidate_caches() + return sqldb.get_scrobble(timestamp=timestamp) return False diff --git a/maloja/web/static/css/maloja.css b/maloja/web/static/css/maloja.css index 5235998..e6f9b65 100644 --- a/maloja/web/static/css/maloja.css +++ b/maloja/web/static/css/maloja.css @@ -525,6 +525,7 @@ table.list tr { background-color: var(--current-bg-color); border-color: var(--current-bg-color); height: 1.45em; + transition: opacity 2s; } @@ -674,6 +675,13 @@ table.list tr.removed { } +table.list tr.changed { + /*background-color: rgba(222,209,180,0.7) !important;*/ + opacity:0; + transition: opacity 0.2s; +} + + /* table td.artists div { overflow:hidden; diff --git a/maloja/web/static/js/edit.js b/maloja/web/static/js/edit.js index ecb08d3..4229ea5 100644 --- a/maloja/web/static/js/edit.js +++ b/maloja/web/static/js/edit.js @@ -43,7 +43,11 @@ function reparseScrobble(id, element) { callback_func = function(req){ if (req.status == 200) { if (req.response.status != 'no_operation') { - window.location.reload(); + //window.location.reload(); + notifyCallback(req); + var newtrack = req.response.scrobble.track; + var row = element.parentElement.parentElement.parentElement.parentElement; + changeScrobbleRow(row,newtrack); } else { notifyCallback(req); @@ -58,6 +62,43 @@ function reparseScrobble(id, element) { } +function changeScrobbleRow(element,newtrack) { + element.classList.add('changed'); + + setTimeout(function(){ + element.getElementsByClassName('track')[0].innerHTML = createTrackCell(newtrack); + },200); + setTimeout(function(){element.classList.remove('changed')},300); +} + +function createTrackCell(trackinfo) { + + var trackquery = new URLSearchParams(); + trackinfo.artists.forEach((a)=>trackquery.append('artist',a)); + trackquery.append('title',trackinfo.title); + + tracklink = document.createElement('a'); + tracklink.href = "/track?" + trackquery.toString(); + tracklink.textContent = trackinfo.title; + + artistelements = [] + var artistholder = document.createElement('span'); + artistholder.classList.add('artist_in_trackcolumn'); + for (var a of trackinfo.artists) { + var artistquery = new URLSearchParams(); + artistquery.append('artist',a); + + artistlink = document.createElement('a'); + artistlink.href = "/artist?" + artistquery.toString(); + artistlink.textContent = a; + + artistelements.push(artistlink.outerHTML) + } + + artistholder.innerHTML = artistelements.join(", "); + return artistholder.outerHTML + " – " + tracklink.outerHTML; +} + // EDIT NAME function editEntity() {