diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 31e0bc9..94ac451 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -744,7 +744,8 @@ def merge_tracks(target_id,source_ids): """Internal Use Only""" result = database.merge_tracks(target_id,source_ids) return { - "status":"success" + "status":"success", + "desc":f"{', '.join(src['title'] for src in result['sources'])} were merged into {result['target']['title']}" } @api.post("merge_artists") @@ -754,7 +755,8 @@ def merge_artists(target_id,source_ids): """Internal Use Only""" result = database.merge_artists(target_id,source_ids) return { - "status":"success" + "status":"success", + "desc":f"{', '.join(src for src in result['sources'])} were merged into {result['target']}" } @api.post("merge_albums") @@ -764,7 +766,8 @@ def merge_artists(target_id,source_ids): """Internal Use Only""" result = database.merge_albums(target_id,source_ids) return { - "status":"success" + "status":"success", + "desc":f"{', '.join(src['albumtitle'] for src in result['sources'])} were merged into {result['target']['albumtitle']}" } @api.post("associate_albums_to_artist") diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index aa57c4e..2eba85f 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -235,7 +235,8 @@ def merge_artists(target_id,source_ids): sources = [sqldb.get_artist(id) for id in source_ids] target = sqldb.get_artist(target_id) log(f"Merging {sources} into {target}") - result = sqldb.merge_artists(target_id,source_ids) + sqldb.merge_artists(target_id,source_ids) + result = {'sources':sources,'target':target} dbcache.invalidate_entity_cache() dbcache.invalidate_caches() @@ -246,7 +247,8 @@ def merge_tracks(target_id,source_ids): sources = [sqldb.get_track(id) for id in source_ids] target = sqldb.get_track(target_id) log(f"Merging {sources} into {target}") - result = sqldb.merge_tracks(target_id,source_ids) + sqldb.merge_tracks(target_id,source_ids) + result = {'sources':sources,'target':target} dbcache.invalidate_entity_cache() dbcache.invalidate_caches() @@ -257,7 +259,8 @@ def merge_albums(target_id,source_ids): sources = [sqldb.get_album(id) for id in source_ids] target = sqldb.get_album(target_id) log(f"Merging {sources} into {target}") - result = sqldb.merge_albums(target_id,source_ids) + sqldb.merge_albums(target_id,source_ids) + result = {'sources':sources,'target':target} dbcache.invalidate_entity_cache() dbcache.invalidate_caches() diff --git a/maloja/web/static/js/edit.js b/maloja/web/static/js/edit.js index 501ae7b..2859708 100644 --- a/maloja/web/static/js/edit.js +++ b/maloja/web/static/js/edit.js @@ -331,7 +331,8 @@ function merge() { callback_func = function(req){ if (req.status == 200) { - window.location.reload(); + notifyCallback(req); + setTimeout(window.location.reload.bind(window.location),1000); } else { notifyCallback(req); @@ -357,18 +358,24 @@ function merge() { function associate() { const lcst = window.sessionStorage; var target_entity_types = {artist:['album','track'], album:['track']}; + var requests_todo = 0; for (var target_entity_type of target_entity_types[entity_type]) { var key = "marked_for_associate_" + target_entity_type; - console.log('get',key); var current_stored = (lcst.getItem(key) || '').split(","); current_stored = current_stored.filter((x)=>x).map((x)=>parseInt(x)); if (current_stored.length != 0) { + requests_todo += 1; callback_func = function(req){ if (req.status == 200) { - //window.location.reload(); + showValidMergeIcons(); notifyCallback(req); + requests_todo -= 1; + if (requests_todo == 0) { + setTimeout(window.location.reload.bind(window.location),1000); + } + } else { notifyCallback(req);