fix: update item counts on bag update

This commit is contained in:
Salikh Gurgenidze
2025-11-16 18:14:48 +04:00
parent a0962d2cc4
commit 9886d33e4e
2 changed files with 47 additions and 3 deletions
+23
View File
@@ -142,6 +142,29 @@ function Tooltip:Initialize()
end
end
end
-- Clear cache function
function Tooltip:ClearCache()
addon:Debug("Tooltip cache cleared")
end
-- Register for bag updates in Initialize
function Tooltip:Initialize()
addon:Print("Initializing tooltip module...")
-- Your existing hook code...
-- Clear cache on bag updates
local frame = CreateFrame("Frame")
frame:RegisterEvent("BAG_UPDATE")
frame:SetScript("OnEvent", function()
if event == "BAG_UPDATE" then
Tooltip:ClearCache()
end
end)
addon:Print("Tooltip item-count integration enabled")
end
addon:Print("Tooltip item-count integration enabled")
end
+24 -3
View File
@@ -76,9 +76,30 @@ end
function BagScanner:SaveToDatabase()
local bagData = self:ScanBags()
addon.Modules.DB:SaveBags(bagData)
addon:Debug("Bag data saved to database")
-- Clear tooltip cache so counts update immediately
if addon.Modules.Tooltip and addon.Modules.Tooltip.ClearCache then
addon.Modules.Tooltip:ClearCache()
end
end
-- Initialize (no auto-save, only save when bags are opened)
-- Initialize with auto-save on bag changes
function BagScanner:Initialize()
addon:Debug("Bag scanner initialized")
end
-- Create event frame for bag updates
local eventFrame = CreateFrame("Frame")
self.eventFrame = eventFrame
-- Register bag update events
eventFrame:RegisterEvent("BAG_UPDATE")
eventFrame:RegisterEvent("BAG_UPDATE_DELAYED")
eventFrame:SetScript("OnEvent", function()
if event == "BAG_UPDATE" or event == "BAG_UPDATE_DELAYED" then
addon:Debug("Bag update detected, saving data...")
self:SaveToDatabase()
end
end)
addon:Debug("Bag scanner initialized with auto-save")
end