perf: add caching and transfer limiting for bag/bank operations

This commit is contained in:
Salikh Gurgenidze
2026-01-24 00:32:30 +04:00
parent 9305b46a85
commit 21efe4c1cc
5 changed files with 291 additions and 38 deletions
+13 -4
View File
@@ -381,8 +381,8 @@ function BagFrame:Update()
displayName = currentViewChar
end
else
-- Viewing current character
bagData = addon.Modules.BagScanner:ScanBags()
-- Viewing current character - use cached data for performance
bagData = addon.Modules.BagScanner:GetBagData()
displayName = UnitName("player") or "Character"
end
@@ -2580,12 +2580,21 @@ function BagFrame:Initialize()
end
-- Update on bag changes (debounced to prevent lag on rapid bag updates)
addon.Modules.Events:OnBagUpdate(function()
-- Register directly to access arg1 (bagID that changed) for incremental cache updates
local bagUpdateFrame = CreateFrame("Frame")
bagUpdateFrame:RegisterEvent("BAG_UPDATE")
bagUpdateFrame:SetScript("OnEvent", function()
if currentViewChar then return end
if not Guda_BagFrame:IsShown() then return end
-- Invalidate only the specific bag that changed (arg1 = bagID)
if arg1 and arg1 >= 0 and arg1 <= 4 then
addon.Modules.BagScanner:InvalidateBag(arg1)
end
-- Use standard delay, will auto-extend if sorting is in progress
ScheduleBagFrameUpdate(0.1)
end, "BagFrame")
end)
-- Update item cooldown overlays when item cooldowns change
addon.Modules.Events:Register("BAG_UPDATE_COOLDOWN", function()
+25 -5
View File
@@ -224,8 +224,8 @@ function BankFrame:Update()
else
-- Viewing current character's bank
if bankIsOpen then
-- Bank is actually open - use live data (interactive mode)
bankData = addon.Modules.BankScanner:ScanBank()
-- Bank is actually open - use cached data for performance
bankData = addon.Modules.BankScanner:GetBankData()
-- Use current character's name for the title
local playerName = addon.Modules.DB:GetPlayerFullName()
getglobal("Guda_BankFrame_Title"):SetText(playerName .. "'s Bank")
@@ -1620,14 +1620,34 @@ function BankFrame:Initialize()
ScheduleBankFrameUpdate(0.15)
end, "BankFrameUI")
-- Register bank-specific update events (pfUI style, debounced)
-- Register bank-specific update events with incremental slot tracking
local updateFrame = CreateFrame("Frame")
updateFrame:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
updateFrame:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED")
updateFrame:RegisterEvent("BAG_UPDATE")
updateFrame:SetScript("OnEvent", function()
if addon.Modules.BankScanner:IsBankOpen() and not currentViewChar then
ScheduleBankFrameUpdate(0.1)
if not addon.Modules.BankScanner:IsBankOpen() then return end
if currentViewChar then return end
if event == "PLAYERBANKSLOTS_CHANGED" and arg1 then
-- Mark specific slot as dirty in main bank (bagID = -1)
addon.Modules.BankScanner:MarkSlotDirty(-1, arg1)
elseif event == "BAG_UPDATE" and arg1 then
-- Check if this is a bank bag (5-10)
if arg1 >= 5 and arg1 <= 10 then
-- Invalidate the specific bank bag (we don't know which slot)
addon.Modules.BankScanner:InvalidateBag(arg1)
else
-- Not a bank bag, ignore for bank frame
return
end
elseif event == "PLAYERBANKBAGSLOTS_CHANGED" then
-- Bank container slot changed (bag added/removed)
-- Must clear entire cache since bag structure changed
addon.Modules.BankScanner:ClearCache()
end
ScheduleBankFrameUpdate(0.1)
end)
end