From d2c7cab3e32f6edf114e4c1d88bcd023eaf5106f Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 28 Aug 2016 12:51:24 +0200 Subject: [PATCH] Prevent smart albums to be part of a selection #603 This bug has been introduced by #603 --- src/scripts/multiselect.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/scripts/multiselect.js b/src/scripts/multiselect.js index 882ce49..714004e 100644 --- a/src/scripts/multiselect.js +++ b/src/scripts/multiselect.js @@ -28,17 +28,10 @@ multiselect.bind = function() { multiselect.toggleItem = function(object, id) { - if (album.isSmartID(id)) return - let pos = $.inArray(id, multiselect.ids) - if (pos!=-1) { - multiselect.ids.splice(pos, 1) - multiselect.deselect(object) - } else { - multiselect.ids.push(id) - multiselect.select(object) - } + if (pos===-1) multiselect.addItem(object, id) + else multiselect.removeItem(object, id) } @@ -46,10 +39,22 @@ multiselect.addItem = function(object, id) { let pos = $.inArray(id, multiselect.ids) - if (pos==-1) { - multiselect.ids.push(id) - multiselect.select(object) - } + if (album.isSmartID(id)) return + if (pos!==-1) return + + multiselect.ids.push(id) + multiselect.select(object) + +} + +multiselect.removeItem = function(object, id) { + + let pos = $.inArray(id, multiselect.ids) + + if (pos===-1) return + + multiselect.ids.splice(pos, 1) + multiselect.deselect(object) }