diff --git a/official/group_persistence.lua b/official/group_persistence.lua index f8060f1..d7ef372 100644 --- a/official/group_persistence.lua +++ b/official/group_persistence.lua @@ -356,38 +356,6 @@ local function has_group_leader_tag(image) return result end -local function build_group(leader) - - if not has_group_leader_tag(leader) then - add_group_leader(leader) - end - - for _, image in ipairs(leader:get_group_members()) do - if not has_group_tag(image) then - add_to_group(image) - end - end -end - -local function process(image_set) - local images - - if image_set == "collection" then - images = dt.collection - else - images = dt.gui.selection() - if #images == 0 then - images = dt.gui.action_images - end - end - - for _, image in ipairs(images) do - if is_group_leader(image) then - build_group(image) - end - end -end - -- handle grouping changes in the UI local function group_exists(group_leader) @@ -470,6 +438,38 @@ local function add_to_group(image, group_leader) end end +local function build_group(leader) + + if not has_group_leader_tag(leader) then + add_group_leader(leader) + end + + for _, image in ipairs(leader:get_group_members()) do + if not has_group_tag(image) then + add_to_group(image) + end + end +end + +local function process(image_set) + local images + + if image_set == "collection" then + images = dt.collection + else + images = dt.gui.selection() + if #images == 0 then + images = dt.gui.action_images + end + end + + for _, image in ipairs(images) do + if is_group_leader(image) then + build_group(image) + end + end +end + local function check_and_remove_empty_group_data(group_tag) if not group_tag then return -- handle duplicate getting deleted