Replace nested if with early return.

This commit is contained in:
voussoir 2020-09-20 12:15:01 -07:00
parent 5c4c0a3034
commit 00bc7e6eac

View file

@ -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);
}
}
</script>