From 0f999f20b393e6ea78865c288a8983e77c530c48 Mon Sep 17 00:00:00 2001 From: Infus Date: Tue, 23 Jan 2024 00:01:33 +0100 Subject: [PATCH] Fix loaded/unloaded if groups or sections weren't expanded Fixes: #4820 --- .../OptionsFrames/OptionsFrame.lua | 13 ++++++------ WeakAurasOptions/WeakAurasOptions.lua | 21 ++++++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua index e451aa1446..c0c21aba03 100644 --- a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua +++ b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua @@ -747,13 +747,14 @@ function OptionsPrivate.CreateFrame() loadedButton:SetCollapseDescription(L["Collapse all loaded displays"]) loadedButton:SetViewClick(function() local suspended = OptionsPrivate.Private.PauseAllDynamicGroups() + if loadedButton.view.visibility == 2 then - for _, child in pairs(loadedButton.childButtons) do + for _, child in ipairs(loadedButton.childButtons) do child:PriorityHide(2) end loadedButton:PriorityHide(2) else - for _, child in pairs(loadedButton.childButtons) do + for _, child in ipairs(loadedButton.childButtons) do child:PriorityShow(2) end loadedButton:PriorityShow(2) @@ -762,7 +763,7 @@ function OptionsPrivate.CreateFrame() end) loadedButton.RecheckVisibility = function(self) local none, all = true, true - for _, child in pairs(loadedButton.childButtons) do + for _, child in ipairs(loadedButton.childButtons) do if child:GetVisibility() ~= 2 then all = false end @@ -810,12 +811,12 @@ function OptionsPrivate.CreateFrame() unloadedButton:SetViewClick(function() local suspended = OptionsPrivate.Private.PauseAllDynamicGroups() if unloadedButton.view.visibility == 2 then - for _, child in pairs(unloadedButton.childButtons) do + for _, child in ipairs(unloadedButton.childButtons) do child:PriorityHide(2) end unloadedButton:PriorityHide(2) else - for _, child in pairs(unloadedButton.childButtons) do + for _, child in ipairs(unloadedButton.childButtons) do child:PriorityShow(2) end unloadedButton:PriorityShow(2) @@ -824,7 +825,7 @@ function OptionsPrivate.CreateFrame() end) unloadedButton.RecheckVisibility = function(self) local none, all = true, true - for _, child in pairs(unloadedButton.childButtons) do + for _, child in ipairs(unloadedButton.childButtons) do if child:GetVisibility() ~= 2 then all = false end diff --git a/WeakAurasOptions/WeakAurasOptions.lua b/WeakAurasOptions/WeakAurasOptions.lua index 09ab30d9b2..0cc969f4da 100644 --- a/WeakAurasOptions/WeakAurasOptions.lua +++ b/WeakAurasOptions/WeakAurasOptions.lua @@ -971,19 +971,18 @@ function OptionsPrivate.UpdateButtonsScroll() frame.buttonsScroll:DoLayout() end -local function addButton(button, aurasMatchingFilter, visible, list) +local function addButton(button, aurasMatchingFilter, visible) button.frame:Show(); if button.AcquireThumbnail then button:AcquireThumbnail() end tinsert(frame.buttonsScroll.children, button); - tinsert(list, button) visible[button] = true if button.data.controlledChildren and button:GetExpanded() then for _, childId in ipairs(button.data.controlledChildren) do if aurasMatchingFilter[childId] then - addButton(displayButtons[childId], aurasMatchingFilter, visible, list) + addButton(displayButtons[childId], aurasMatchingFilter, visible) end end end @@ -1167,11 +1166,17 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id) table.sort(topLevelLoadedAuras, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(topLevelLoadedAuras) do if aurasMatchingFilter[id] then - addButton(displayButtons[id], aurasMatchingFilter, visible, frame.loadedButton.childButtons) + addButton(displayButtons[id], aurasMatchingFilter, visible) end end end + for _, id in ipairs(topLevelLoadedAuras) do + for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do + tinsert(frame.loadedButton.childButtons, displayButtons[child.id]) + end + end + tinsert(frame.buttonsScroll.children, frame.unloadedButton); wipe(frame.unloadedButton.childButtons) @@ -1179,11 +1184,17 @@ function OptionsPrivate.SortDisplayButtons(filter, overrideReset, id) table.sort(topLevelUnloadedAuras, function(a, b) return a:lower() < b:lower() end) for _, id in ipairs(topLevelUnloadedAuras) do if aurasMatchingFilter[id] then - addButton(displayButtons[id], aurasMatchingFilter, visible, frame.unloadedButton.childButtons) + addButton(displayButtons[id], aurasMatchingFilter, visible) end end end + for _, id in ipairs(topLevelUnloadedAuras) do + for child in OptionsPrivate.Private.TraverseAllChildren(WeakAuras.GetData(id)) do + tinsert(frame.unloadedButton.childButtons, displayButtons[child.id]) + end + end + for _, child in pairs(displayButtons) do if(not visible[child]) then child.frame:Hide();