perf: batch learner pin refreshes
This commit is contained in:
+32
-14
@@ -425,23 +425,45 @@ local function _GetDB() return Questie.dbLearner.global end
|
|||||||
-- Triggers QuestieQuest:UpdateQuest for every active quest in the player's log
|
-- Triggers QuestieQuest:UpdateQuest for every active quest in the player's log
|
||||||
-- that is referenced in the provided set (table with questId keys).
|
-- that is referenced in the provided set (table with questId keys).
|
||||||
-- Called after cross-linking so map pins refresh immediately.
|
-- Called after cross-linking so map pins refresh immediately.
|
||||||
local function _RefreshActiveQuestPins(questIdSet)
|
local _pendingQuestPinRefreshes = {}
|
||||||
|
local _pendingQuestPinRefreshTimer = nil
|
||||||
|
|
||||||
|
local function _FlushActiveQuestPins()
|
||||||
|
local questIdSet = _pendingQuestPinRefreshes
|
||||||
|
_pendingQuestPinRefreshes = {}
|
||||||
|
_pendingQuestPinRefreshTimer = nil
|
||||||
|
|
||||||
|
if not next(questIdSet) then return end
|
||||||
if not QuestieQuest or not QuestieQuest.UpdateQuest then return end
|
if not QuestieQuest or not QuestieQuest.UpdateQuest then return end
|
||||||
if not QuestiePlayer or not QuestiePlayer.currentQuestlog then return end
|
if not QuestiePlayer or not QuestiePlayer.currentQuestlog then return end
|
||||||
-- Skip scheduling when the set is empty (avoids no-op timer callbacks)
|
|
||||||
if not next(questIdSet) then return end
|
|
||||||
local timer = (C_Timer) or (QuestieCompat and QuestieCompat.C_Timer)
|
|
||||||
for questId in pairs(questIdSet) do
|
for questId in pairs(questIdSet) do
|
||||||
if QuestiePlayer.currentQuestlog[questId] then
|
if QuestiePlayer.currentQuestlog[questId] then
|
||||||
if timer then
|
QuestieQuest:UpdateQuest(questId)
|
||||||
timer.After(0.1, function() QuestieQuest:UpdateQuest(questId) end)
|
|
||||||
else
|
|
||||||
QuestieQuest:UpdateQuest(questId)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function _RefreshActiveQuestPins(questIdSet)
|
||||||
|
-- Skip scheduling when the set is empty (avoids no-op timer callbacks)
|
||||||
|
if not next(questIdSet) then return end
|
||||||
|
for questId in pairs(questIdSet) do
|
||||||
|
_pendingQuestPinRefreshes[questId] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if _pendingQuestPinRefreshTimer then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local timer = (C_Timer) or (QuestieCompat and QuestieCompat.C_Timer)
|
||||||
|
if timer and timer.After then
|
||||||
|
_pendingQuestPinRefreshTimer = true
|
||||||
|
timer.After(0.15, _FlushActiveQuestPins)
|
||||||
|
else
|
||||||
|
_FlushActiveQuestPins()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Invalidates cached objective.spawnList for any active quest whose objectives
|
-- Invalidates cached objective.spawnList for any active quest whose objectives
|
||||||
-- reference the given npcId. Unloads existing world/minimap icons, resets
|
-- reference the given npcId. Unloads existing world/minimap icons, resets
|
||||||
-- tooltip registration, and forces the map system to rebuild spawn lists from
|
-- tooltip registration, and forces the map system to rebuild spawn lists from
|
||||||
@@ -1572,11 +1594,7 @@ function QuestieLearner:LearnQuestObjectiveNPC(questId, npcId, objText, objectiv
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 3. Re-process the quest so PopulateObjective registers tooltips & map pins
|
-- 3. Re-process the quest so PopulateObjective registers tooltips & map pins
|
||||||
if QuestieQuest and QuestieQuest.UpdateQuest then
|
_RefreshActiveQuestPins({ [questId] = true })
|
||||||
QuestieCompat.C_Timer.After(0.5, function()
|
|
||||||
QuestieQuest:UpdateQuest(questId)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 3. Register with tooltip system immediately. Preserve the objective icon so
|
-- 3. Register with tooltip system immediately. Preserve the objective icon so
|
||||||
-- nameplates can render the correct learned slay/loot/talk marker.
|
-- nameplates can render the correct learned slay/loot/talk marker.
|
||||||
|
|||||||
Reference in New Issue
Block a user