From 1b71ee617f2ca6d8ffcc2cc81e150497773f9a64 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri, 30 Oct 2026 21:44:37 -0500 Subject: [PATCH] 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. --- modules/loothistory.lua | 26 ++++++++++---------------- modules/panel.lua | 16 +++++----------- modules/swingtimer.lua | 8 ++------ skins/blizzard/mail.lua | 19 ++++++++++++------- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/modules/loothistory.lua b/modules/loothistory.lua index 3e276b17..ba0e2bf3 100644 --- a/modules/loothistory.lua +++ b/modules/loothistory.lua @@ -209,23 +209,17 @@ pfUI:RegisterModule("loothistory", function () local isExpanded = rollID and expanded[rollID] SetToggleTexture(f.toggle, isExpanded) - -- Item icon/name/quality via the ClassicAPI Item mixin. When the item - -- isn't cached yet, show a placeholder and re-paint this row from the - -- ContinueOnItemLoad callback (guarded on rollID: rows are pooled, so the + -- Item icon/name/quality via the ClassicAPI Item mixin. The row shows a + -- placeholder until ContinueOnItemLoad paints it, which happens at once + -- 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). - local item = itemLink and Item:CreateFromItemLink(itemLink) - if item and not item:IsItemEmpty() then - if item:IsItemDataCached() then - RenderItemVisual(f, item) - else - ShowRetrieving(f) - local pending = rollID - item:ContinueOnItemLoad(function() - if f.rollID == pending then RenderItemVisual(f, item) end - end) - end - else - ShowRetrieving(f) + ShowRetrieving(f) + if itemLink then + local item = Item:CreateFromItemLink(itemLink) + local pending = rollID + item:ContinueOnItemLoad(function() + if f.rollID == pending then RenderItemVisual(f, item) end + end) end -- winner summary only on a decided, collapsed row diff --git a/modules/panel.lua b/modules/panel.lua index c57e8865..ca431ab9 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -575,18 +575,12 @@ pfUI:RegisterModule("panel", function() blindpowder = 5530 } + -- runs at once when the item is cached local function AddItemToPanel(panelType) - local itemID = itemIDs[panelType] - if C_Item.IsItemDataCachedByID(itemID) then - local itemName, count = C_Item.GetItemNameByID(itemID), C_Item.GetItemCount(itemID) - pfUI.panel:OutputPanel(panelType, itemName .. ": " .. count) - 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 + local item = Item:CreateFromItemID(itemIDs[panelType]) + item:ContinueOnItemLoad(function() + pfUI.panel:OutputPanel(panelType, item:GetItemName() .. ": " .. C_Item.GetItemCount(item:GetItemID())) + end) end local class = UnitClassBase('player') diff --git a/modules/swingtimer.lua b/modules/swingtimer.lua index 734dbc75..afb1738e 100644 --- a/modules/swingtimer.lua +++ b/modules/swingtimer.lua @@ -258,12 +258,8 @@ pfUI:RegisterModule("swingtimer", function () -- weapons (22); main-hand-only (21) can never sit there. local OH_WEAPON_TYPES = { [13]=true, [22]=true } local function HasOffhandWeapon() - local l = GetInventoryItemLink("player", 17) - if not l then return false end - 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 + local invType = C_Item.GetItemInventoryType({ equipmentSlotIndex = INVSLOT_OFFHAND }) + return OH_WEAPON_TYPES[invType] == true end local function UpdateWeaponSpeeds() diff --git a/skins/blizzard/mail.lua b/skins/blizzard/mail.lua index d4d00856..b780308c 100644 --- a/skins/blizzard/mail.lua +++ b/skins/blizzard/mail.lua @@ -63,14 +63,19 @@ pfUI:RegisterSkin("Mailbox", function () SkinButton(OpenMailPackageButton, nil, nil, nil, OpenMailPackageButtonIconTexture) 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) - if itemID then - local quality = C_Item.GetItemQualityByID(itemID) - local r,g,b = GetItemQualityColor(quality) - OpenMailPackageButton:SetBackdropBorderColor(r,g,b,1) - else - OpenMailPackageButton:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color)) - end + if not itemID then return end + local item = Item:CreateFromItemID(itemID) + item:ContinueOnItemLoad(function() + local quality = item:GetItemQuality() + if quality and InboxFrame.openMailID == index then + local r,g,b = GetItemQualityColor(quality) + OpenMailPackageButton:SetBackdropBorderColor(r,g,b,1) + end + end) end) end