fix: bug
This commit is contained in:
+20
-15
@@ -52,24 +52,29 @@ function BankScanner:GetBankData()
|
||||
if cacheValid and bankCache then
|
||||
-- Process any dirty slots incrementally
|
||||
for bagID, slots in pairs(dirtySlots) do
|
||||
if bankCache[bagID] then
|
||||
for slotID in pairs(slots) do
|
||||
local oldData = bankCache[bagID].slots[slotID]
|
||||
local newData = addon.Modules.BagScanner:ScanSlot(bagID, slotID)
|
||||
bankCache[bagID].slots[slotID] = newData
|
||||
if bagID ~= nil and type(slots) == "table" then
|
||||
if bankCache[bagID] then
|
||||
for slotID in pairs(slots) do
|
||||
-- Validate slotID is a valid number
|
||||
if type(slotID) == "number" and slotID >= 1 then
|
||||
local oldData = bankCache[bagID].slots[slotID]
|
||||
local newData = addon.Modules.BagScanner:ScanSlot(bagID, slotID)
|
||||
bankCache[bagID].slots[slotID] = newData
|
||||
|
||||
-- Update free slot count
|
||||
local wasEmpty = (oldData == nil)
|
||||
local isEmpty = (newData == nil)
|
||||
if wasEmpty and not isEmpty then
|
||||
bankCache[bagID].freeSlots = bankCache[bagID].freeSlots - 1
|
||||
elseif not wasEmpty and isEmpty then
|
||||
bankCache[bagID].freeSlots = bankCache[bagID].freeSlots + 1
|
||||
-- Update free slot count
|
||||
local wasEmpty = (oldData == nil)
|
||||
local isEmpty = (newData == nil)
|
||||
if wasEmpty and not isEmpty then
|
||||
bankCache[bagID].freeSlots = bankCache[bagID].freeSlots - 1
|
||||
elseif not wasEmpty and isEmpty then
|
||||
bankCache[bagID].freeSlots = bankCache[bagID].freeSlots + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Bag not in cache, scan it
|
||||
bankCache[bagID] = self:ScanBankBag(bagID)
|
||||
end
|
||||
else
|
||||
-- Bag not in cache, scan it
|
||||
bankCache[bagID] = self:ScanBankBag(bagID)
|
||||
end
|
||||
end
|
||||
dirtySlots = {}
|
||||
|
||||
Reference in New Issue
Block a user