From 5ee34c50a46f1b24a55e3badc292ae5c23e2f919 Mon Sep 17 00:00:00 2001 From: Nils Asmussen Date: Sat, 13 Aug 2016 16:03:37 +0200 Subject: [PATCH] Properly redirect after album {delete,move,merge}. That is, we don't redirect to the albums view, but to the current album or the parent album if the current one has been deleted. --- src/scripts/album.js | 50 +++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/scripts/album.js b/src/scripts/album.js index 346a19b..31902c0 100644 --- a/src/scripts/album.js +++ b/src/scripts/album.js @@ -256,6 +256,21 @@ album.delete = function(albumIDs) { albums.deleteByID(id) }) + } else if (visible.album()) { + + // if we deleted the current album, go to its parent + if (albumIDs.length==1 && album.json.id==albumIDs[0]) { + + let id = album.getParent() + album.refresh() + lychee.goto(id) + + } + // otherwise, we deleted a subalbum + else { + album.reload() + } + } else { albums.refresh() @@ -684,12 +699,8 @@ album.merge = function(albumIDs, titles = []) { api.post('Album::merge', params, function(data) { - if (data!==true) { - lychee.error(null, params, data) - } else { - albums.refresh() - lychee.goto() - } + if (data!==true) lychee.error(null, params, data) + else album.reload() }) @@ -724,12 +735,8 @@ album.move = function(albumIDs, titles = []) { api.post('Album::move', params, function(data) { - if (data!==true) { - lychee.error(null, params, data) - } else { - albums.refresh() - lychee.goto() - } + if (data!==true) lychee.error(null, params, data) + else album.reload() }) @@ -750,4 +757,23 @@ album.move = function(albumIDs, titles = []) { } }) +} + +album.reload = function() { + + let albumID = album.getID() + + album.refresh() + albums.refresh() + + if (visible.album()) lychee.goto(albumID) + else lychee.goto() + +} + +album.refresh = function() { + + album.json = null + album.subjson = null + } \ No newline at end of file