Change the sort algorithm to use UnitExist instead of frame:IsShown

When UNIT_PET fires, pet units will exist but the UnitWatch will not yet
have shown the frame.
This commit is contained in:
omicron committed 2026-06-24 00:37:15 +02:00
1 parent 77ae4ddad3
commit 86e5ed78b0
1 file changed
+7 -11
+7 -11
View File
@@ -32,9 +32,10 @@ local function RoleValue(role)
end end
local function UnitFrameDefaultCompare(lhs, rhs) local function UnitFrameDefaultCompare(lhs, rhs)
-- visible < invisible -- exists < not exists
if lhs.secureFrame:IsShown() ~= rhs.secureFrame:IsShown() then local lexists, rexists = UnitExists(lhs.unit), UnitExists(rhs.unit)
return lhs.secureFrame:IsShown() if lexists ~= rexists then
return lexists
end end
local lunit, runit = lhs.unit, rhs.unit local lunit, runit = lhs.unit, rhs.unit
@@ -69,7 +70,6 @@ function UnitGroup:Init(left, top, width, height)
self.top = top self.top = top
self.left = left self.left = left
self.units = {} self.units = {}
self.sortAfterCombat = false
self:RegisterEvents() self:RegisterEvents()
end end
@@ -104,18 +104,14 @@ function UnitGroup:PLAYER_REGEN_ENABLED()
end end
function UnitGroup:OnLeaveCombat() function UnitGroup:OnLeaveCombat()
if self.sortAfterCombat then self:Sort()
self:Sort()
self.sortAfterCombat = false
end
end end
function UnitGroup:OnRosterUpdate() function UnitGroup:OnRosterUpdate()
if InCombatLockdown() then if InCombatLockdown() then
self.sortAfterCombat = true return
else
self:Sort()
end end
self:Sort()
end end
function UnitGroup:AddUnitFrame(unit) function UnitGroup:AddUnitFrame(unit)