Wait on ContinueOnItemLoad for inbox, panel and loot history items

The inbox package border now waits for the item to load, since another
player's item may not be cached. The panel and loot history drop their
cached branch: ContinueOnItemLoad runs at once for a cached item. The
swing timer reads the off-hand inventory type from the slot instead of
parsing the item link.
This commit is contained in:
Brues
2026-10-30 21:44:37 -05:00
parent bfe1864aa1
commit 1b71ee617f
4 changed files with 29 additions and 40 deletions
+10 -16
View File
@@ -209,23 +209,17 @@ pfUI:RegisterModule("loothistory", function ()
local isExpanded = rollID and expanded[rollID] local isExpanded = rollID and expanded[rollID]
SetToggleTexture(f.toggle, isExpanded) SetToggleTexture(f.toggle, isExpanded)
-- Item icon/name/quality via the ClassicAPI Item mixin. When the item -- Item icon/name/quality via the ClassicAPI Item mixin. The row shows a
-- isn't cached yet, show a placeholder and re-paint this row from the -- placeholder until ContinueOnItemLoad paints it, which happens at once
-- ContinueOnItemLoad callback (guarded on rollID: rows are pooled, so the -- when the item is cached (guarded on rollID: rows are pooled, so the
-- callback must no-op if the row has since been reused for another roll). -- callback must no-op if the row has since been reused for another roll).
local item = itemLink and Item:CreateFromItemLink(itemLink) ShowRetrieving(f)
if item and not item:IsItemEmpty() then if itemLink then
if item:IsItemDataCached() then local item = Item:CreateFromItemLink(itemLink)
RenderItemVisual(f, item) local pending = rollID
else item:ContinueOnItemLoad(function()
ShowRetrieving(f) if f.rollID == pending then RenderItemVisual(f, item) end
local pending = rollID end)
item:ContinueOnItemLoad(function()
if f.rollID == pending then RenderItemVisual(f, item) end
end)
end
else
ShowRetrieving(f)
end end
-- winner summary only on a decided, collapsed row -- winner summary only on a decided, collapsed row
+5 -11
View File
@@ -575,18 +575,12 @@ pfUI:RegisterModule("panel", function()
blindpowder = 5530 blindpowder = 5530
} }
-- runs at once when the item is cached
local function AddItemToPanel(panelType) local function AddItemToPanel(panelType)
local itemID = itemIDs[panelType] local item = Item:CreateFromItemID(itemIDs[panelType])
if C_Item.IsItemDataCachedByID(itemID) then item:ContinueOnItemLoad(function()
local itemName, count = C_Item.GetItemNameByID(itemID), C_Item.GetItemCount(itemID) pfUI.panel:OutputPanel(panelType, item:GetItemName() .. ": " .. C_Item.GetItemCount(item:GetItemID()))
pfUI.panel:OutputPanel(panelType, itemName .. ": " .. count) end)
else
local item = Item:CreateFromItemID(itemID)
item:ContinueOnItemLoad(function()
local itemName, count = item:GetItemName(), C_Item.GetItemCount(item:GetItemID())
pfUI.panel:OutputPanel(panelType, itemName .. ": " .. count)
end)
end
end end
local class = UnitClassBase('player') local class = UnitClassBase('player')
+2 -6
View File
@@ -258,12 +258,8 @@ pfUI:RegisterModule("swingtimer", function ()
-- weapons (22); main-hand-only (21) can never sit there. -- weapons (22); main-hand-only (21) can never sit there.
local OH_WEAPON_TYPES = { [13]=true, [22]=true } local OH_WEAPON_TYPES = { [13]=true, [22]=true }
local function HasOffhandWeapon() local function HasOffhandWeapon()
local l = GetInventoryItemLink("player", 17) local invType = C_Item.GetItemInventoryType({ equipmentSlotIndex = INVSLOT_OFFHAND })
if not l then return false end return OH_WEAPON_TYPES[invType] == true
local _, _, id = string.find(l, "item:(%d+)")
id = tonumber(id)
if not id then return false end
return OH_WEAPON_TYPES[C_Item.GetItemInventoryTypeByID(id)] == true
end end
local function UpdateWeaponSpeeds() local function UpdateWeaponSpeeds()
+12 -7
View File
@@ -63,14 +63,19 @@ pfUI:RegisterSkin("Mailbox", function ()
SkinButton(OpenMailPackageButton, nil, nil, nil, OpenMailPackageButtonIconTexture) SkinButton(OpenMailPackageButton, nil, nil, nil, OpenMailPackageButtonIconTexture)
hooksecurefunc("InboxFrame_OnClick", function(index) hooksecurefunc("InboxFrame_OnClick", function(index)
OpenMailPackageButton:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color))
-- another player's item may not be cached yet
local _, itemID = GetInboxItemLink(index) local _, itemID = GetInboxItemLink(index)
if itemID then if not itemID then return end
local quality = C_Item.GetItemQualityByID(itemID) local item = Item:CreateFromItemID(itemID)
local r,g,b = GetItemQualityColor(quality) item:ContinueOnItemLoad(function()
OpenMailPackageButton:SetBackdropBorderColor(r,g,b,1) local quality = item:GetItemQuality()
else if quality and InboxFrame.openMailID == index then
OpenMailPackageButton:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color)) local r,g,b = GetItemQualityColor(quality)
end OpenMailPackageButton:SetBackdropBorderColor(r,g,b,1)
end
end)
end) end)
end end