In addon:OnEnable(): Register for TRADE_SKILL_UPDATE
torhal [12-11-09 - 00:21]
In addon:OnEnable(): Register for TRADE_SKILL_UPDATE
Added addon:TRADE_SKILL_UPDATE() which re-scans (on a throttle so the client doesn't lock up) the recipes so the list automatically updates when you learn a new recipe. Only works if the tradeskill frame is open.
diff --git a/ARL.lua b/ARL.lua
index b3bbf3d..3df26a6 100644
--- a/ARL.lua
+++ b/ARL.lua
@@ -536,6 +536,7 @@ end
function addon:OnEnable()
self:RegisterEvent("TRADE_SKILL_SHOW") -- Make addon respond to the tradeskill windows being shown
self:RegisterEvent("TRADE_SKILL_CLOSE") -- Addon responds to tradeskill windows being closed.
+ self:RegisterEvent("TRADE_SKILL_UPDATE")
if addon.db.profile.scantrainers then
self:RegisterEvent("TRAINER_SHOW")
@@ -786,6 +787,33 @@ function addon:TRADE_SKILL_CLOSE()
end
end
+do
+ local last_update = 0
+ local updater = CreateFrame("Frame", nil, UIParent)
+
+ updater:Hide()
+ updater:SetScript("OnUpdate",
+ function(self, elapsed)
+ last_update = last_update + elapsed
+
+ if last_update >= 0.5 then
+ addon:Scan(false)
+ self:Hide()
+ end
+ end)
+
+ function addon:TRADE_SKILL_UPDATE()
+ if not self.Frame:IsVisible() then
+ return
+ end
+
+ if not updater:IsVisible() then
+ last_update = 0
+ updater:Show()
+ end
+ end
+end
+
-------------------------------------------------------------------------------
-- Tradeskill functions
-- Recipe DB Structures are defined in Documentation.lua