diff --git a/data/refresh.lua b/data/refresh.lua index 13896fec..b0585874 100644 --- a/data/refresh.lua +++ b/data/refresh.lua @@ -82,6 +82,7 @@ function refresh:StartUpdate(ctx) local updateBank = false local sortBackpack = false local wipeAndRefreshAll = false + ctx:Set('wipe', false) for _, event in pairs(self.UpdateQueue) do if event.ctx:GetBool("wipe") then -- Prevent full wipes from happening in combat. @@ -106,6 +107,8 @@ function refresh:StartUpdate(ctx) updateBank = true elseif event.eventName == 'WIPE_AND_REFRESH_ALL' then wipeAndRefreshAll = true + elseif event.eventName == 'BAG_UPDATE_ONLY' then + updateBackpack = true elseif const.BANK_BAGS[event.args[1]] then updateBank = true elseif const.REAGENTBANK_BAGS[event.args[1]] then @@ -139,7 +142,11 @@ function refresh:StartUpdate(ctx) if addon.atWarbank and addon.Bags.Bank.bankTab < const.BANK_TAB.ACCOUNT_BANK_1 then addon.Bags.Bank.bankTab = const.BANK_TAB.ACCOUNT_BANK_1 end + if updateBackpack then + table.insert(refresh.UpdateQueue, {eventName = 'BAG_UPDATE_ONLY', args = {const.BAG_KIND.BACKPACK}, ctx = ctx:Copy()}) + end items:RefreshBank(ctx:Copy()) + return end if updateBackpack then @@ -249,6 +256,13 @@ function refresh:OnEnable() self:StartUpdate(ctx) end) + events:RegisterMessage('bags/Draw/Bank/Done', function(ctx) + self.isUpdateRunning = false + if next(self.UpdateQueue) ~= nil then + self:StartUpdate(ctx) + end + end) + -- Register for when bags are done drawing. events:RegisterMessage('bags/Draw/Backpack/Done', function(ctx) -- If there are more updates in the queue, start the next one with a new context. @@ -256,8 +270,6 @@ function refresh:OnEnable() self.backpackRedrawPending = false if next(self.UpdateQueue) ~= nil then self:StartUpdate(ctx) - else - ctx:Cancel() end end) diff --git a/frames/bag.lua b/frames/bag.lua index 0a8eecfb..4ed94aaf 100644 --- a/frames/bag.lua +++ b/frames/bag.lua @@ -302,7 +302,7 @@ end function bagFrame.bagProto:Draw(ctx, slotInfo, callback) local viewList = self.views[database:GetBagView(self.kind)] local updateView = viewList[1] == self.currentView and viewList[2] or viewList[1] - local previousView = self.currentView + local previousView = updateView == viewList[1] and viewList[2] or viewList[1] --if self.currentView and self.currentView:GetBagView() ~= updateView:GetBagView() then -- self.currentView:Wipe(ctx) diff --git a/views/bagview.lua b/views/bagview.lua index 6e3487aa..126d582e 100644 --- a/views/bagview.lua +++ b/views/bagview.lua @@ -48,7 +48,7 @@ end ---@param ctx Context ---@param view View local function WipeSections(ctx, view) - debug:StartProfile('Bag View Sections Wipe') + debug:StartProfile('Bag View Sections Wipe %d', view.kind) for _, section in pairs(view.sections) do async:RawBatch(ctx, 10, section:GetCellList(), function(bctx, cell) cell:Release(bctx) @@ -57,7 +57,7 @@ local function WipeSections(ctx, view) end wipe(view.sections) wipe(view.itemsByBagAndSlot) - debug:EndProfile('Bag View Sections Wipe') + debug:EndProfile('Bag View Sections Wipe %d', view.kind) end ---@param bagid number @@ -159,10 +159,10 @@ local function BagView(view, ctx, bag, slotInfo, callback) async:Chain(ctx, nil, function(ectx) if ectx:GetBool('wipe') then - debug:StartProfile('Wipe Loop') + debug:StartProfile('Wipe Loop %d', bag.kind) view:Wipe(ectx) WipeSections(ectx, view) - debug:EndProfile('Wipe Loop') + debug:EndProfile('Wipe Loop %d', bag.kind) end end, function(ectx) @@ -218,13 +218,13 @@ local function BagView(view, ctx, bag, slotInfo, callback) view.content:Sort(function(a, b) return sort.SortSectionsAlphabetically(view.kind, a, b) end) - debug:StartProfile('Content Draw Stage') + debug:StartProfile('Content Draw Stage %d', bag.kind) local w, h = view.content:Draw({ cells = view.content.cells, maxWidthPerRow = ((37 + 4) * sizeInfo.itemsPerRow) + 16, columns = sizeInfo.columnCount, }) - debug:EndProfile('Content Draw Stage') + debug:EndProfile('Content Draw Stage %d', bag.kind) -- Reposition the content frame if the recent items section is empty. if w < 160 then w = 160 diff --git a/views/gridview.lua b/views/gridview.lua index 4f0dea67..6900163b 100644 --- a/views/gridview.lua +++ b/views/gridview.lua @@ -41,9 +41,9 @@ local debug = addon:GetModule('Debug') ---@param ctx Context local function Wipe(view, ctx) debug:Log("Wipe", "Grid View Wipe") - debug:StartProfile('Grid View Content Wipe') + debug:StartProfile('Grid View Content Wipe %d', view.kind) view.content:Wipe() - debug:EndProfile('Grid View Content Wipe') + debug:EndProfile('Grid View Content Wipe %d', view.kind) if view.freeSlot ~= nil then view.freeSlot:Release(ctx) view.freeSlot = nil @@ -58,7 +58,7 @@ end ---@param ctx Context ---@param view View local function WipeSections(ctx, view) - debug:StartProfile('Grid View Sections Wipe') + debug:StartProfile('Grid View Sections Wipe %d', view.kind) for _, section in pairs(view.sections) do async:RawBatch(ctx, 10, section:GetCellList(), function(bctx, cell) cell:Release(bctx) @@ -67,7 +67,7 @@ local function WipeSections(ctx, view) end wipe(view.sections) wipe(view.itemsByBagAndSlot) - debug:EndProfile('Grid View Sections Wipe') + debug:EndProfile('Grid View Sections Wipe %d', view.kind) end -- ClearButton clears a button and makes it empty while preserving the slot, @@ -257,14 +257,14 @@ local function GridView(view, ctx, bag, slotInfo, callback) async:Chain(ctx, nil, function(ectx) if ectx:GetBool('wipe') then - debug:StartProfile('Wipe Loop') + debug:StartProfile('Wipe Loop %d', bag.kind) view:Wipe(ectx) WipeSections(ectx, view) - debug:EndProfile('Wipe Loop') + debug:EndProfile('Wipe Loop %d', bag.kind) end end, function(ectx) - debug:StartProfile('Removed Loop') + debug:StartProfile('Removed Loop %d', bag.kind) async:RawBatch(ectx, 15, removed, function(bctx, item) local stackInfo = slotInfo.stacks:GetStackInfo(item.itemHash) if not stackInfo then @@ -279,10 +279,10 @@ local function GridView(view, ctx, bag, slotInfo, callback) UpdateButton(bctx, view, stackInfo.rootItem) end end) - debug:EndProfile('Removed Loop') + debug:EndProfile('Removed Loop %d', bag.kind) end, function(ectx) - debug:StartProfile('Added Loop') + debug:StartProfile('Added Loop %d', bag.kind) async:RawBatch(ectx, 15, added, function(bctx, item) local stackInfo = slotInfo.stacks:GetStackInfo(item.itemHash) ---- Check stacking options @@ -298,10 +298,10 @@ local function GridView(view, ctx, bag, slotInfo, callback) ReconcileStack(bctx, view, stackInfo) end end) - debug:EndProfile('Added Loop') + debug:EndProfile('Added Loop %d', bag.kind) end, function(ectx) - debug:StartProfile('Changed Loop') + debug:StartProfile('Changed Loop %d', bag.kind) async:RawBatch(ectx, 15, changed, function(bctx, item) local stackInfo = slotInfo.stacks:GetStackInfo(item.itemHash) if not stackInfo then @@ -326,10 +326,10 @@ local function GridView(view, ctx, bag, slotInfo, callback) end end end) - debug:EndProfile('Changed Loop') + debug:EndProfile('Changed Loop %d', bag.kind) end, function(ectx) - debug:StartProfile('Everything Else') + debug:StartProfile('Everything Else %d', bag.kind) -- Special handling for Recent Items -- add it to the dirty sections if -- it has no items visible. local recentItemsSection = view:GetSection(L:G("Recent Items")) @@ -460,7 +460,7 @@ local function GridView(view, ctx, bag, slotInfo, callback) bag.frame:SetHeight(bagHeight) UpdateViewSize(view) view.itemCount = slotInfo.totalItems - debug:EndProfile('Everything Else') + debug:EndProfile('Everything Else %d', bag.kind) end, callback) end