fix: purge lingering completed quest icons
This commit is contained in:
+71
-11
@@ -127,19 +127,18 @@ function QuestieMap:UnloadQuestFramesForObjective(questId, objectiveIndex)
|
||||
end
|
||||
|
||||
function QuestieMap:UnloadQuestFrames(questId, iconType)
|
||||
if not iconType then
|
||||
QuestieMap:PurgeQuestFrames(questId)
|
||||
Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieMap] Unloading quest frames for questid:", questId)
|
||||
return
|
||||
end
|
||||
|
||||
if QuestieMap.questIdFrames[questId] then
|
||||
if not iconType then
|
||||
for _, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do
|
||||
for name, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do
|
||||
if frame and frame.data and frame.data.Icon == iconType then
|
||||
frame:Unload();
|
||||
end
|
||||
QuestieMap.questIdFrames[questId] = nil;
|
||||
else
|
||||
for name, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do
|
||||
if frame and frame.data and frame.data.Icon == iconType then
|
||||
frame:Unload();
|
||||
QuestieMap.questIdFrames[questId][name] = nil
|
||||
_G[name] = nil
|
||||
end
|
||||
QuestieMap.questIdFrames[questId][name] = nil
|
||||
_G[name] = nil
|
||||
end
|
||||
end
|
||||
Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieMap] Unloading quest frames for questid:", questId)
|
||||
@@ -257,6 +256,67 @@ function QuestieMap:DequeueFrameDrawCalls(frame)
|
||||
end
|
||||
end
|
||||
|
||||
function QuestieMap:PurgeQuestFrames(questId)
|
||||
if not questId then return end
|
||||
|
||||
local frames = {}
|
||||
for _, frame in pairs(QuestieMap:GetFramesForQuest(questId)) do
|
||||
if frame then
|
||||
frames[frame] = true
|
||||
end
|
||||
end
|
||||
|
||||
local function collectQueuedFrames(queue)
|
||||
if type(queue) ~= "table" then return end
|
||||
for i = #queue, 1, -1 do
|
||||
local frame = queue[i] and queue[i][2]
|
||||
if frame and frame.data and frame.data.Id == questId then
|
||||
frames[frame] = true
|
||||
tremove(queue, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
collectQueuedFrames(QuestieMap._mapDrawQueue)
|
||||
collectQueuedFrames(QuestieMap._minimapDrawQueue)
|
||||
|
||||
local function collectHbdFrames(pinTable)
|
||||
if type(pinTable) ~= "table" then return end
|
||||
for frame in pairs(pinTable) do
|
||||
if frame and frame.data and frame.data.Id == questId then
|
||||
frames[frame] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if HBDPins then
|
||||
collectHbdFrames(HBDPins.activeMinimapPins)
|
||||
collectHbdFrames(HBDPins.worldmapPins)
|
||||
end
|
||||
|
||||
for frame in pairs(frames) do
|
||||
if frame.Unload then
|
||||
frame:Unload()
|
||||
else
|
||||
if HBDPins then
|
||||
HBDPins:RemoveMinimapIcon(Questie, frame)
|
||||
HBDPins:RemoveWorldMapIcon(Questie, frame)
|
||||
end
|
||||
if frame.Hide then frame:Hide() end
|
||||
if frame.ClearAllPoints then frame:ClearAllPoints() end
|
||||
end
|
||||
|
||||
if frame.GetName then
|
||||
local frameName = frame:GetName()
|
||||
if frameName then
|
||||
_G[frameName] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
QuestieMap.questIdFrames[questId] = nil
|
||||
end
|
||||
|
||||
--- Called at startup (Stage 3) and on PLAYER_ENTERING_WORLD to reset the draw queue.
|
||||
function QuestieMap:InitializeQueue()
|
||||
Questie:Debug(Questie.DEBUG_DEVELOP, "[QuestieMap] Starting draw queue timer!")
|
||||
|
||||
@@ -607,13 +607,15 @@ function _QuestEventHandler:CleanupRemovedQuestsFallback()
|
||||
-- Check if this quest was confirmed as turned in (not just objectives complete)
|
||||
local wasTurnedIn = questLog[questId] and questLog[questId].state == QUEST_LOG_STATES.QUEST_TURNED_IN
|
||||
local wasAlreadyComplete = Questie.db.char.complete and Questie.db.char.complete[questId]
|
||||
local completeAtRemoval = QuestieDB.IsComplete(questId)
|
||||
local shouldComplete = wasTurnedIn or wasAlreadyComplete or completeAtRemoval == 1
|
||||
|
||||
QuestLogCache.RemoveQuest(questId)
|
||||
QuestieQuest:SetObjectivesDirty(questId)
|
||||
|
||||
-- Only mark as complete if it was actually turned in OR already marked complete from previous session
|
||||
-- Don't use quest.WasComplete because that's set when objectives complete, not when quest is turned in
|
||||
if wasTurnedIn or wasAlreadyComplete then
|
||||
if shouldComplete then
|
||||
QuestieQuest:CompleteQuest(questId)
|
||||
else
|
||||
QuestieQuest:AbandonedQuest(questId)
|
||||
|
||||
@@ -652,7 +652,7 @@ local function _CleanupCompletedQuestObjectivePins(quest)
|
||||
end
|
||||
end
|
||||
|
||||
QuestieMap:UnloadQuestFrames(quest.Id)
|
||||
QuestieMap:PurgeQuestFrames(quest.Id)
|
||||
end
|
||||
|
||||
---@param questId number
|
||||
|
||||
Reference in New Issue
Block a user