Skip to content

Commit

Permalink
unsubscribe text updates when text is not visible
Browse files Browse the repository at this point in the history
Fixes #2598

Signed-off-by: Allen Faure <[email protected]>
  • Loading branch information
emptyrivers committed Jan 9, 2023
1 parent 1b88deb commit 591c4d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
4 changes: 3 additions & 1 deletion WeakAuras/RegionTypes/RegionPrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ local SubRegionEventSystem =
end,

RemoveSubscriber = function(self, event, subRegion)
tremove(self.events[event], tIndexOf(self.events[event], subRegion))
if self.events[event] then
tremove(self.events[event], tIndexOf(self.events[event], subRegion))
end
end,

Notify = function(self, event, ...)
Expand Down
34 changes: 22 additions & 12 deletions WeakAuras/SubRegionTypes/SubText.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,18 +309,6 @@ local function modify(parent, region, parentData, data, first)
region.FrameTick = FrameTick
region.TimerTick = TimerTick

if Update then
parent.subRegionEvents:AddSubscriber("Update", region)
end

if FrameTick then
parent.subRegionEvents:AddSubscriber("FrameTick", region)
end

if TimerTick then
parent.subRegionEvents:AddSubscriber("TimerTick", region)
end

if not UpdateText then
if text:GetFont() then
local textStr = data.text_text
Expand Down Expand Up @@ -357,7 +345,29 @@ local function modify(parent, region, parentData, data, first)
function region:SetVisible(visible)
if visible then
self:Show()
if self.Update then
parent.subRegionEvents:AddSubscriber("Update", region)
end

if self.FrameTick then
parent.subRegionEvents:AddSubscriber("FrameTick", region)
end

if self.TimerTick then
parent.subRegionEvents:AddSubscriber("TimerTick", region)
end
else
if self.Update then
parent.subRegionEvents:RemoveSubscriber("Update", region)
end

if self.FrameTick then
parent.subRegionEvents:RemoveSubscriber("FrameTick", region)
end

if self.TimerTick then
parent.subRegionEvents:RemoveSubscriber("TimerTick", region)
end
self:Hide()
end
end
Expand Down

0 comments on commit 591c4d6

Please sign in to comment.