fix: refresh trackedItemBar and QuestItemBar at the end of sort

This commit is contained in:
Vati
2026-03-10 02:15:34 +04:00
parent 61924d4180
commit f6ff579ce5
4 changed files with 26 additions and 62 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
## Title: Guda
## Notes: All-in-one bag and bank addon for World of Warcraft 1.12.1 (Turtle WoW)
## Author: Vati
## Version: 2.0.4
## Version: 2.0.5
## SavedVariables: Guda_DB
## SavedVariablesPerCharacter: Guda_CharDB
+21 -61
View File
@@ -1826,6 +1826,22 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort
addon:DebugSort("Starting %s sort (estimated: %d passes, safety limit: %d)", sortType, maxPasses, safetyLimit)
local function FinishSort()
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags"
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
-- Refresh bars that were suppressed during sorting
if addon.Modules.QuestItemBar then addon.Modules.QuestItemBar:Update() end
if addon.Modules.TrackedItemBar then addon.Modules.TrackedItemBar:Update() end
end
local function DoSortPass()
passCount = passCount + 1
@@ -1845,38 +1861,14 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort
addon:DebugSort("%s sort complete! (%d passes, %d total moves)", sortType, passCount, totalMoves)
-- Final update (cache clearing happens after delay, uses pooled timer)
Guda_ScheduleTimer(0.3, function()
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags" -- Reset sort context
-- Clear bag position cache - item properties don't change on move
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
end)
Guda_ScheduleTimer(0.3, FinishSort)
elseif passCount >= safetyLimit then
-- Hit safety limit but not fully sorted
addon:DebugSort("%s sort stopped at safety limit! (%d/%d items still need sorting after %d passes)",
sortType, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems, passCount)
-- Final update (cache clearing happens after delay, uses pooled timer)
Guda_ScheduleTimer(0.3, function()
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags" -- Reset sort context
-- Clear bag position cache - item properties don't change on move
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
end)
Guda_ScheduleTimer(0.3, FinishSort)
else
-- No progress guard: stop if we make no moves repeatedly
if moveCount == 0 then
@@ -1890,19 +1882,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort
sortType, passCount, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems)
-- Final update (cache clearing happens after delay, uses pooled timer)
Guda_ScheduleTimer(0.3, function()
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags" -- Reset sort context
-- Clear bag position cache - item properties don't change on move
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
end)
Guda_ScheduleTimer(0.3, FinishSort)
return
end
@@ -1918,18 +1898,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort
addon:DebugSort("%s sort stuck: items not decreasing after %d passes with moves (remaining: %d/%d)",
sortType, stuckPasses, currentAnalysis.itemsOutOfPlace, currentAnalysis.totalItems)
Guda_ScheduleTimer(0.3, function()
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags"
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
end)
Guda_ScheduleTimer(0.3, FinishSort)
return
end
@@ -1958,16 +1927,7 @@ function SortEngine:ExecuteSort(sortFunction, analyzeFunction, updateFrame, sort
Guda_ScheduleTimer(hardTimeout, function()
if SortEngine.sortingInProgress then
addon:DebugSort("%s sort force-stopped after %ds timeout", sortType, hardTimeout)
if sfxCVar then pcall(SetCVar, sfxCVar, originalSFX) end
SortEngine.sortingInProgress = false
SortEngine:UpdateSortButtonState(false)
currentSortType = "bags"
if sortType == "bank" then
addon.Modules.BankScanner:ClearCache()
else
addon.Modules.BagScanner:ClearCache()
end
updateFrame()
FinishSort()
end
end)
+2
View File
@@ -647,6 +647,8 @@ function QuestItemBar:Initialize()
-- Register for events with debouncing to prevent lag on rapid bag updates
local bagUpdatePending = false
addon.Modules.Events:Register("BAG_UPDATE", function()
-- Skip updates while sorting is in progress (sort completion will trigger update)
if addon.Modules.SortEngine and addon.Modules.SortEngine.sortingInProgress then return end
if bagUpdatePending then return end
bagUpdatePending = true
-- Debounce: wait 0.15 seconds before updating (uses pooled timer)
+2
View File
@@ -373,6 +373,8 @@ function TrackedItemBar:Initialize()
-- Register for events with debouncing to prevent lag on rapid bag updates
local bagUpdatePending = false
addon.Modules.Events:Register("BAG_UPDATE", function()
-- Skip updates while sorting is in progress (sort completion will trigger update)
if addon.Modules.SortEngine and addon.Modules.SortEngine.sortingInProgress then return end
if bagUpdatePending then return end
bagUpdatePending = true
-- Debounce: wait 0.15 seconds before updating (uses pooled timer)