Skip to content

Commit

Permalink
[fix] Improve event processing for GROUP_ROSTER_UPDATE and UNIT_AURA …
Browse files Browse the repository at this point in the history
…event

Related to #330
  • Loading branch information
BreakBB committed Nov 12, 2024
1 parent f22f7ff commit 9009261
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Modules/EventHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ local DEBOUNCE_INTERVAL = 0.5 -- 0.5 seconds debounce interval
---Event handler for all the events subscribed to in _Init.RegisterEvents
function EventHandler.HandleOnEvent(_, event, ...)
local currentTime = GetTime()
if currentTime - lastEventTime < DEBOUNCE_INTERVAL then
return -- Ignore the event if it's within the debounce interval
end
local shouldDebounce = currentTime - lastEventTime < DEBOUNCE_INTERVAL
lastEventTime = currentTime

if event == "GROUP_ROSTER_UPDATE" then
if (not shouldDebounce) and event == "GROUP_ROSTER_UPDATE" then
-- Someone joined or left the group
currentGroupMembers = GetNumGroupMembers()
elseif event == "UNIT_AURA" or event == "PLAYER_LEVEL_UP" or event == "CHARACTER_POINTS_CHANGED" then
elseif ((not shouldDebounce) and event == "UNIT_AURA") or event == "PLAYER_LEVEL_UP" or event == "CHARACTER_POINTS_CHANGED" then
if currentGroupMembers > 5 then
-- When in a raid update on the next UPDATE_INTERVAL tick
shouldUpdate = true
Expand Down

0 comments on commit 9009261

Please sign in to comment.