From 00bc7e6eaca99d74a905694e2b6bac34262f98f0 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 20 Sep 2020 12:15:01 -0700 Subject: [PATCH] Replace nested if with early return. --- .../etiquette_flask/templates/album.html | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/frontends/etiquette_flask/templates/album.html b/frontends/etiquette_flask/templates/album.html index a6fb535..6f14972 100644 --- a/frontends/etiquette_flask/templates/album.html +++ b/frontends/etiquette_flask/templates/album.html @@ -426,17 +426,19 @@ function on_album_drag_drop(event) const child_title = child.querySelector('.album_card_title').textContent.trim(); const parent_title = parent.querySelector('.album_card_title').textContent.trim(); - if (confirm(`Move\n${child_title}\ninto\n${parent_title}?`)) + const prompt = `Move\n${child_title}\ninto\n${parent_title}?`; + if (! confirm(prompt)) { - if (ALBUM_ID) - { - api.albums.add_child(parent_id, child_id, null); - api.albums.remove_child(ALBUM_ID, child_id, common.refresh); - } - else - { - api.albums.add_child(parent_id, child_id, common.refresh); - } + return; + } + if (ALBUM_ID) + { + api.albums.add_child(parent_id, child_id, null); + api.albums.remove_child(ALBUM_ID, child_id, common.refresh); + } + else + { + api.albums.add_child(parent_id, child_id, common.refresh); } }