diff WorldQuests.lua @ 103:8cdd62e7a224

- Solved the quest pins remaining visible issue
author Nenue
date Sun, 28 May 2017 19:50:42 -0400
parents fbd4ead2a19f
children 9f664a0ef8a8
line wrap: on
line diff
--- a/WorldQuests.lua	Thu May 18 16:44:05 2017 -0400
+++ b/WorldQuests.lua	Sun May 28 19:50:42 2017 -0400
@@ -45,6 +45,7 @@
 local BountyBoard = WorldMapFrame.UIElementsFrame.BountyBoard
 local ActionButton = WorldMapFrame.UIElementsFrame.ActionButton
 local defaults = {}
+local completedQuests = {}
 
 local continentScanned
 local layoutDirty = true
@@ -135,6 +136,7 @@
   elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then
     local questID = ...
     if questID and db.QuestsByID[questID] then
+      completedQuests[questID] = true
       db.QuestsByID[questID]:Release()
     end
     self:Refresh(event)
@@ -331,7 +333,8 @@
 end
 
 function Module:UpdateBounties(...)
-    print('|cFF00FF88BountyInfo()|r', ...)
+  bountiesDirty = nil
+  print('|cFF00FF88BountyInfo()|r', ...)
   wipe(db.BountiesByFactionID)
   wipe(db.BountiesByQuestID)
 
@@ -353,7 +356,6 @@
         print(' ', index, info.factionID, GetQuestLogTitle(GetQuestLogIndexByID(info.questID)), info.complete, (index == selectedBountyIndex) and 'SELECTED' or '')
       end
   end
-  bountiesDirty = nil
 end
 
 -- check current artifact knowledge and update pins accordingly
@@ -410,6 +412,11 @@
     print(msg, lastRefresh, ...)
   end
 
+
+  if bountiesDirty then
+    self:UpdateBounties()
+  end
+
   if not db.Config.EnablePins then
     numShown = 0
     self.refreshBenchMark = GetTime()
@@ -577,12 +584,16 @@
   if not (questID and QuestUtils_IsQuestWorldQuest(questID)) then
     return nil
   end
-  if IsQuestComplete(questID) then
+  local pin = db.QuestsByID[questID]
+  -- check to avoid creating unnecessary frames
+  if IsQuestComplete(questID) or completedQuests[questID] then
+    completedQuests[questID] = true
+    if pin then
+      pin:Release()
+    end
     return nil
   end
 
-
-  local pin = db.QuestsByID[questID]
   if not pin then
     local numFree = #db.FreePins
     if numFree >= 1 then
@@ -606,10 +617,7 @@
     tinsert(db.UsedPins, pin)
   end
 
-  if IsQuestComplete(questID) then
-    pin:Release()
-    return nil
-  elseif info then
+  if info then
     pin.inProgress = info.inProgress
     pin.floor = info.floor
     pin.numObjectives = info.numObjectives or 0