fix: bag freezing screen on initial open
This commit is contained in:
+9
-6
@@ -102,25 +102,28 @@ local function CancelDeferredUsabilityCheck()
|
||||
end
|
||||
end
|
||||
|
||||
-- Update usability tints on all visible item buttons
|
||||
local function UpdateAllUsabilityTints()
|
||||
-- Update usability tints on all visible item buttons — cache-only.
|
||||
-- Every SetBagItem tooltip scan on a cold item can block 50-500ms, so we
|
||||
-- never trigger scans from the bag-open path. Tints appear for items
|
||||
-- already cached; uncached items stay untinted until CacheWarmer fills
|
||||
-- them in (its BagFrame hook triggers a re-sweep when done).
|
||||
function Guda_BagFrame_UpdateAllUsabilityTints()
|
||||
if not Guda_BagFrame or not Guda_BagFrame:IsShown() then return end
|
||||
-- Don't scan ~80 tooltips synchronously while the user is dragging the
|
||||
-- frame — it can stall the engine for multiple seconds on cold caches.
|
||||
-- The caller will reschedule after the drag ends.
|
||||
if isFrameMoving then return end
|
||||
|
||||
for _, bagParent in pairs(bagParents) do
|
||||
if bagParent and bagParent.itemButtons then
|
||||
for button in pairs(bagParent.itemButtons) do
|
||||
if button.hasItem and button:IsShown() and Guda_ItemButton_UpdateUsableTint then
|
||||
Guda_ItemButton_UpdateUsableTint(button)
|
||||
Guda_ItemButton_UpdateUsableTint(button, true) -- cacheOnly
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local UpdateAllUsabilityTints = Guda_BagFrame_UpdateAllUsabilityTints
|
||||
|
||||
-- Schedule a deferred usability check with debouncing
|
||||
local function ScheduleDeferredUsabilityCheck()
|
||||
-- Create frame on first use
|
||||
|
||||
+12
-2
@@ -42,9 +42,19 @@ function Guda_CategorizeItem(itemData, bagID, slotID, categories, specialItems,
|
||||
return
|
||||
end
|
||||
|
||||
-- Use CategoryManager rule engine if available, otherwise fall back to legacy logic
|
||||
-- Use CategoryManager rule engine if available, otherwise fall back to legacy logic.
|
||||
-- Fast path: cache-only lookup. CacheWarmer populates categoryCache in the
|
||||
-- background; on cold miss we skip rule evaluation (which would otherwise
|
||||
-- trigger tooltip scans per item) and use itemData.class as a rough bucket.
|
||||
-- CacheWarmer's completion marker re-triggers BagFrame:Update so items land
|
||||
-- in their real categories once warmup finishes.
|
||||
if addon.Modules.CategoryManager then
|
||||
cat = addon.Modules.CategoryManager:CategorizeItem(itemData, bagID, slotID, isOtherChar)
|
||||
if addon.Modules.CategoryManager.CategorizeItemCached then
|
||||
cat = addon.Modules.CategoryManager:CategorizeItemCached(itemData, isOtherChar)
|
||||
end
|
||||
if not cat then
|
||||
cat = itemData.class or "Miscellaneous"
|
||||
end
|
||||
if not categories[cat] then cat = "Miscellaneous" end
|
||||
table.insert(categories[cat], {bagID = bagID, slotID = slotID, itemData = itemData})
|
||||
return
|
||||
|
||||
+17
-5
@@ -848,8 +848,10 @@ end
|
||||
-- The old IsItemUnusable, IsRedColor, and durabilityPattern have been removed
|
||||
-- to prevent redundant tooltip scanning - all detection is now centralized.
|
||||
|
||||
-- Apply/remove red tint on item texture for unusable items
|
||||
local function Guda_ItemButton_UpdateUsableTint(self)
|
||||
-- Apply/remove red tint on item texture for unusable items.
|
||||
-- When cacheOnly is true, skips the tooltip scan on cold cache and returns
|
||||
-- untinted — the deferred pass in BagFrame fills in tints later.
|
||||
local function Guda_ItemButton_UpdateUsableTint(self, cacheOnly)
|
||||
-- Clear any existing tint/overlay first
|
||||
if self.unusableOverlay and self.unusableOverlay.Hide then
|
||||
self.unusableOverlay:Hide()
|
||||
@@ -880,7 +882,16 @@ local function Guda_ItemButton_UpdateUsableTint(self)
|
||||
-- Use cached detection from ItemDetection module (avoids duplicate tooltip scans)
|
||||
local unusable = false
|
||||
if self.itemData and addon.Modules.ItemDetection then
|
||||
unusable = addon.Modules.ItemDetection:IsUnusable(self.itemData, self.bagID, self.slotID)
|
||||
if cacheOnly then
|
||||
local cached = addon.Modules.ItemDetection:IsUnusableCached(self.itemData)
|
||||
if cached == nil then
|
||||
-- Unknown; leave untinted. Deferred pass fills this in later.
|
||||
return
|
||||
end
|
||||
unusable = cached
|
||||
else
|
||||
unusable = addon.Modules.ItemDetection:IsUnusable(self.itemData, self.bagID, self.slotID)
|
||||
end
|
||||
end
|
||||
|
||||
-- Ensure overlay exists (created in OnLoad, but be defensive)
|
||||
@@ -1885,9 +1896,10 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha
|
||||
if cd and cd.Hide then cd:Hide() end
|
||||
end
|
||||
|
||||
-- Update unusable red overlay tint
|
||||
-- Update unusable red overlay tint (cache-only on the layout path;
|
||||
-- deferred pass in BagFrame runs the full scan spread via QueueWork).
|
||||
if Guda_ItemButton_UpdateUsableTint then
|
||||
Guda_ItemButton_UpdateUsableTint(self)
|
||||
Guda_ItemButton_UpdateUsableTint(self, true)
|
||||
end
|
||||
else
|
||||
-- Clear empty slot
|
||||
|
||||
Reference in New Issue
Block a user