Skip to content

Commit

Permalink
Item Count: Add support for reagent/account bank api (#5389)
Browse files Browse the repository at this point in the history
  • Loading branch information
InfusOnWoW authored Sep 6, 2024
1 parent fb285c3 commit 9dfba8d
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2268,19 +2268,21 @@ do
end,
Schedule = function(self, expirationTime, id)
if (not self.expirationTime[id] or expirationTime < self.expirationTime[id]) and expirationTime > 0 then
if self.handles[id] then
timer:CancelTimer(self.handles[id])
self.handles[id] = nil
self.expirationTime[id] = nil
end

self:Cancel(id)
local duration = expirationTime - GetTime()
if duration > 0 then
self.handles[id] = timer:ScheduleTimerFixed(self.Recheck, duration, self, id)
self.expirationTime[id] = expirationTime
end
end
end
end,
Cancel = function(self, id)
if self.handles[id] then
timer:CancelTimer(self.handles[id])
self.handles[id] = nil
self.expirationTime[id] = nil
end
end,
}

local function FetchSpellCooldown(self, id)
Expand Down Expand Up @@ -2419,7 +2421,7 @@ do
--- @field name string
--- @field icon number
--- @field id number
--- @field watched number[]
--- @field watched table<number, boolean>

-- Basic details like name, icon, charges, times per effective spell id
-- Also contains the mapping from effective spell id to watched
Expand Down Expand Up @@ -2465,10 +2467,10 @@ do
name = name,
icon = icon,
id = spellId,
watched = { effectiveSpellId }
watched = { [effectiveSpellId] = true }
}
if effectiveSpellId ~= userSpellId then
tinsert(self.data[effectiveSpellId].watched, userSpellId)
self.data[effectiveSpellId].watched[userSpellId] = true
end

local spellDetail = self.data[effectiveSpellId]
Expand Down Expand Up @@ -2506,10 +2508,10 @@ do
-- There are lots of cases to consider here:

-- For the new effective spell id
-- a) We are already tracking it, only add the wathed spell ids
-- a) We are already tracking it, only add the watched spell ids
-- b) We aren't tracking it yet add it
if self.data[newEffectiveSpellId] then
tinsert(self.data[newEffectiveSpellId].watched, userSpellId)
self.data[newEffectiveSpellId].watched[userSpellId] = true
else
self:AddEffectiveSpellId(newEffectiveSpellId, userSpellId)
end
Expand All @@ -2530,9 +2532,10 @@ do
-- For the old effective spell id
-- * Remove the spell from watched
-- * If we removed the last mapping, remove the spell details of the effective spell id
tremove(oldSpellDetail.watched, userSpellId)
if #oldSpellDetail.watched == 0 then
oldSpellDetail.watched[userSpellId] = nil
if next(oldSpellDetail.watched) == nil then
self.data[oldEffectiveSpellId] = nil
RecheckHandles:Cancel(oldEffectiveSpellId)
end

-- Finally update the watchedSpellIds mapping
Expand Down Expand Up @@ -2671,9 +2674,7 @@ do

if self.data[effectiveSpellId] then
-- But we are already tracking the effectiveSpellId, so only add the mapping
if not tContains(self.data[effectiveSpellId].watched, userSpellId) then
tinsert(self.data[effectiveSpellId].watched, userSpellId)
end
self.data[effectiveSpellId].watched[userSpellId] = true
return
end

Expand All @@ -2683,7 +2684,7 @@ do
SendEventsForSpell = function(self, effectiveSpellId, event, ...)
local watchedSpells = self.data[effectiveSpellId] and self.data[effectiveSpellId].watched
if watchedSpells then
for _, userSpellId in ipairs(watchedSpells) do
for userSpellId in pairs(watchedSpells) do
Private.ScanEventsByID(event, userSpellId, ...)
end
end
Expand Down

0 comments on commit 9dfba8d

Please sign in to comment.