From 382723fb5f42adbc6c023c02c7fe59f752b7e5b3 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Thu, 3 Sep 2026 16:45:44 +0200 Subject: [PATCH] Keep Vendor Values cache fallback synchronous --- mods/vendor-values.lua | 57 ++++-------------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/mods/vendor-values.lua b/mods/vendor-values.lua index 00f77fa..6021875 100644 --- a/mods/vendor-values.lua +++ b/mods/vendor-values.lua @@ -3317,43 +3317,17 @@ local function GetVendorPrice(id) return ShaguTweaks.SellValueDB and ShaguTweaks.SellValueDB[id] end -local pendingTooltip, pendingItemID, pendingCount, pendingIgnoreMerchant - -local function ClearPending(frame) - if not frame or pendingTooltip == frame then - pendingTooltip, pendingItemID, pendingCount, pendingIgnoreMerchant = - nil, nil, nil, nil - end -end - local function AddVendorPrices(frame, id, count, ignoreMerchant) if not frame or not id then return end - if not ignoreMerchant and MerchantFrame:IsShown() then - ClearPending(frame) - return - end + if not ignoreMerchant and MerchantFrame:IsShown() then return end local price = GetVendorPrice(id) count = math.max(tonumber(count) or 1, 1) - if price ~= nil then - ClearPending(frame) - if price > 0 then - SetTooltipMoney(frame, price * count) - frame:Show() - return true - end - return - end - - -- ClassicAPI returns nil for an uncached record and starts loading it. - -- Remember only one visible tooltip; the event handler below retries once - -- the exact item arrives. - if API and API.itemprice then - pendingTooltip = frame - pendingItemID = id - pendingCount = count - pendingIgnoreMerchant = ignoreMerchant + if price and price > 0 then + SetTooltipMoney(frame, price * count) + frame:Show() + return true end end @@ -3363,27 +3337,6 @@ local function AddVendorPriceFromLink(frame, link, count, ignoreMerchant) end module.enable = function(self) - -- Refresh a tooltip whose ClassicAPI item record was still loading. This is - -- event-driven and completely dormant when no item price is pending. - if API and API.eventutils and _G.C_EventUtils - and _G.C_EventUtils.IsEventValid("GET_ITEM_INFO_RECEIVED") then - local priceEvents = CreateFrame("Frame") - priceEvents:RegisterEvent("GET_ITEM_INFO_RECEIVED") - priceEvents:SetScript("OnEvent", function() - if not pendingTooltip or not pendingItemID or arg1 ~= pendingItemID then - return - end - - if not pendingTooltip:IsShown() then - ClearPending() - return - end - - AddVendorPrices( - pendingTooltip, pendingItemID, pendingCount, pendingIgnoreMerchant) - end) - end - -- Every tooltip setter is described once here. Prefer ClassicAPI's direct -- item IDs; link parsing remains only as a cold compatibility path inside -- api.lua or for SetHyperlink/SetCraftSpell where a link is the natural API.