1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Can now reparse without reloading

This commit is contained in:
krateng 2022-04-25 20:48:22 +02:00
parent 2c31df3c58
commit 9c6c91f594
4 changed files with 55 additions and 3 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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;

View File

@ -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() {