Browse Source

Bugfix: BulkQuery->QueryTicker spammed errors if items list was empty

pull/13/head
xan-asc 2 years ago
parent
commit
369f1985d3
  1. 33
      TradeSkillMaster/TradeSkillMaster.lua

33
TradeSkillMaster/TradeSkillMaster.lua

@ -134,7 +134,7 @@ local savedDBDefaults = {
-- Called once the player has loaded WOW. -- Called once the player has loaded WOW.
function TSM:OnInitialize() function TSM:OnInitialize()
TSMAPI:RegisterForTracing(TSMAPI, "TSMAPI") TSMAPI:RegisterForTracing(TSMAPI, "TSMAPI")
TSM.moduleObjects = nil TSM.moduleObjects = nil
TSM.moduleNames = nil TSM.moduleNames = nil
@ -149,7 +149,7 @@ function TSM:OnInitialize()
else else
TSM.operations = TSM.db.profile.operations TSM.operations = TSM.db.profile.operations
end end
-- Prepare the TradeSkillMasterAppDB database -- Prepare the TradeSkillMasterAppDB database
-- We're not using AceDB here on purpose due to bugs in AceDB, but are emulating the parts of it that we need. -- We're not using AceDB here on purpose due to bugs in AceDB, but are emulating the parts of it that we need.
@ -250,7 +250,7 @@ function TSM:OnInitialize()
end end
end end
TSMAPI:BulkQuery(bulkquerybuffer) TSMAPI:BulkQuery(bulkquerybuffer)
if TSM.db.profile.deValueSource then if TSM.db.profile.deValueSource then
TSM.db.profile.destroyValueSource = TSM.db.profile.deValueSource TSM.db.profile.destroyValueSource = TSM.db.profile.deValueSource
TSM.db.profile.deValueSource = nil TSM.db.profile.deValueSource = nil
@ -267,7 +267,7 @@ function TSM:RegisterModule()
} }
TSM.priceSources = {} TSM.priceSources = {}
-- Auctioneer -- Auctioneer
if select(4, GetAddOnInfo("Auc-Advanced")) == 1 and AucAdvanced then if select(4, GetAddOnInfo("Auc-Advanced")) == 1 and AucAdvanced then
if AucAdvanced.Modules.Util.Appraiser and AucAdvanced.Modules.Util.Appraiser.GetPrice then if AucAdvanced.Modules.Util.Appraiser and AucAdvanced.Modules.Util.Appraiser.GetPrice then
@ -280,7 +280,7 @@ function TSM:RegisterModule()
tinsert(TSM.priceSources, { key = "AucMarket", label = L["Auctioneer - Market Value"], callback = AucAdvanced.API.GetMarketValue }) tinsert(TSM.priceSources, { key = "AucMarket", label = L["Auctioneer - Market Value"], callback = AucAdvanced.API.GetMarketValue })
end end
end end
-- Auctionator -- Auctionator
if select(4, GetAddOnInfo("Auctionator")) == 1 and Atr_GetAuctionBuyout then if select(4, GetAddOnInfo("Auctionator")) == 1 and Atr_GetAuctionBuyout then
tinsert(TSM.priceSources, { key = "AtrValue", label = L["Auctionator - Auction Value"], callback = Atr_GetAuctionBuyout }) tinsert(TSM.priceSources, { key = "AtrValue", label = L["Auctionator - Auction Value"], callback = Atr_GetAuctionBuyout })
@ -430,7 +430,7 @@ function TSM:GetTooltip(itemString, quantity)
tinsert(text, { left = " " .. L["Disenchant Value:"], right = TSMAPI:FormatTextMoney(deValue, "|cffffffff", true) }) tinsert(text, { left = " " .. L["Disenchant Value:"], right = TSMAPI:FormatTextMoney(deValue, "|cffffffff", true) })
end end
end end
if TSM.db.profile.detailedDestroyTooltip then if TSM.db.profile.detailedDestroyTooltip then
local _, itemLink, quality, ilvl, _, iType = TSMAPI:GetSafeItemInfo(itemString) local _, itemLink, quality, ilvl, _, iType = TSMAPI:GetSafeItemInfo(itemString)
local itemString = TSMAPI:GetItemString(itemLink) local itemString = TSMAPI:GetItemString(itemLink)
@ -463,7 +463,7 @@ function TSM:GetTooltip(itemString, quantity)
end end
end end
end end
-- add mill value info -- add mill value info
if TSM.db.profile.millTooltip then if TSM.db.profile.millTooltip then
local millValue = TSM:GetMillValue(itemString) local millValue = TSM:GetMillValue(itemString)
@ -481,7 +481,7 @@ function TSM:GetTooltip(itemString, quantity)
tinsert(text, { left = " " .. L["Mill Value:"], right = TSMAPI:FormatTextMoney(millValue, "|cffffffff", true) }) tinsert(text, { left = " " .. L["Mill Value:"], right = TSMAPI:FormatTextMoney(millValue, "|cffffffff", true) })
end end
end end
if TSM.db.profile.detailedDestroyTooltip then if TSM.db.profile.detailedDestroyTooltip then
for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("mill")) do for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("mill")) do
local herbs = TSMAPI:GetItemConversions(targetItem) local herbs = TSMAPI:GetItemConversions(targetItem)
@ -504,7 +504,7 @@ function TSM:GetTooltip(itemString, quantity)
end end
end end
end end
-- add prospect value info -- add prospect value info
if TSM.db.profile.prospectTooltip then if TSM.db.profile.prospectTooltip then
local prospectValue = TSM:GetProspectValue(itemString) local prospectValue = TSM:GetProspectValue(itemString)
@ -522,7 +522,7 @@ function TSM:GetTooltip(itemString, quantity)
tinsert(text, { left = " " .. L["Prospect Value:"], right = TSMAPI:FormatTextMoney(prospectValue, "|cffffffff", true) }) tinsert(text, { left = " " .. L["Prospect Value:"], right = TSMAPI:FormatTextMoney(prospectValue, "|cffffffff", true) })
end end
end end
if TSM.db.profile.detailedDestroyTooltip then if TSM.db.profile.detailedDestroyTooltip then
for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("prospect")) do for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("prospect")) do
local gems = TSMAPI:GetItemConversions(targetItem) local gems = TSMAPI:GetItemConversions(targetItem)
@ -589,7 +589,7 @@ function TSM:GetTooltip(itemString, quantity)
end end
end end
end end
for name, method in pairs(TSM.db.global.customPriceSources) do for name, method in pairs(TSM.db.global.customPriceSources) do
if TSM.db.global.customPriceTooltips[name] then if TSM.db.global.customPriceTooltips[name] then
local price = TSM:GetCustomPrice(name, itemString) local price = TSM:GetCustomPrice(name, itemString)
@ -632,7 +632,7 @@ end
function TSM:GetMillValue(itemString) function TSM:GetMillValue(itemString)
local value = 0 local value = 0
for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("mill")) do for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("mill")) do
local herbs = TSMAPI:GetItemConversions(targetItem) local herbs = TSMAPI:GetItemConversions(targetItem)
if herbs[itemString] then if herbs[itemString] then
@ -640,13 +640,13 @@ function TSM:GetMillValue(itemString)
value = value + (matValue or 0) * herbs[itemString].rate value = value + (matValue or 0) * herbs[itemString].rate
end end
end end
return value return value
end end
function TSM:GetProspectValue(itemString) function TSM:GetProspectValue(itemString)
local value = 0 local value = 0
for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("prospect")) do for _, targetItem in ipairs(TSMAPI:GetConversionTargetItems("prospect")) do
local gems = TSMAPI:GetItemConversions(targetItem) local gems = TSMAPI:GetItemConversions(targetItem)
if gems[itemString] then if gems[itemString] then
@ -654,7 +654,7 @@ function TSM:GetProspectValue(itemString)
value = value + (matValue or 0) * gems[itemString].rate value = value + (matValue or 0) * gems[itemString].rate
end end
end end
return value return value
end end
@ -716,6 +716,7 @@ end
-- Bulk load uncached IDs. Divides in to buckets of 50 -- Bulk load uncached IDs. Divides in to buckets of 50
function TSMAPI:BulkQuery(items) function TSMAPI:BulkQuery(items)
if not items or #items == 0 then return end
self.QueryTicker = Timer.NewTicker(1, function() self.QueryTicker = Timer.NewTicker(1, function()
Item:BulkContinueOnLoad(table.take(items, 50), function(id) end, function(id) return GetItemInfo(id) == nil end) -- 3rd parameter (validator) is optional Item:BulkContinueOnLoad(table.take(items, 50), function(id) end, function(id) return GetItemInfo(id) == nil end) -- 3rd parameter (validator) is optional
if #items == 0 then if #items == 0 then
@ -723,4 +724,4 @@ function TSMAPI:BulkQuery(items)
self.QueryTicker = nil self.QueryTicker = nil
end end
end) end)
end end

Loading…
Cancel
Save