From 06615cf96e3c0dbde3ddcbed7fe71987d13a51e7 Mon Sep 17 00:00:00 2001 From: Salikh Gurgenidze Date: Sat, 24 Jan 2026 02:18:28 +0400 Subject: [PATCH] fix: swap issue on bank frame --- UI/ItemButton.lua | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/UI/ItemButton.lua b/UI/ItemButton.lua index 7dc2ec6..1501ef7 100644 --- a/UI/ItemButton.lua +++ b/UI/ItemButton.lua @@ -960,21 +960,33 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha local itemQuality, itemLink, isLocked if not self.isReadOnly and bagID and slotID and self.hasItem then -- Query live game state for metadata - local _, _, locked, quality = GetContainerItemInfo(bagID, slotID) - itemLink = GetContainerItemLink(bagID, slotID) - itemQuality = quality - isLocked = locked + -- Special handling for bank main bag (bagID == -1) which uses inventory slot API + if self.isBank and bagID == -1 then + local invSlot = 39 + slotID + itemLink = GetInventoryItemLink("player", invSlot) + isLocked = IsInventoryItemLocked(invSlot) + -- Quality will be determined from GetItemInfo below + else + local _, _, locked, quality = GetContainerItemInfo(bagID, slotID) + itemLink = GetContainerItemLink(bagID, slotID) + itemQuality = quality + isLocked = locked + end -- Ensure itemData is populated for live items (needed for ItemDetection) if itemLink then local itemName, _, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemLink) + -- For bank main bag, get quality from GetItemInfo + if self.isBank and bagID == -1 then + itemQuality = itemRarity + end if not itemData then -- Create new itemData if itemName then itemData = { link = itemLink, name = itemName, - quality = itemRarity or quality or 0, + quality = itemRarity or itemQuality or 0, class = itemType, subclass = itemSubType, texture = itemTexture, @@ -983,12 +995,15 @@ function Guda_ItemButton_SetItem(self, bagID, slotID, itemData, isBank, otherCha self.itemData = itemData end else - -- Update existing itemData with missing fields - if not itemData.link then itemData.link = itemLink end - if itemData.quality == nil then itemData.quality = itemRarity or quality or 0 end + -- ALWAYS update itemData.link with live link to ensure correct detection after swaps + -- This is critical: cached itemData might have stale link from before a swap + itemData.link = itemLink + -- Update other fields only if missing + if itemData.quality == nil then itemData.quality = itemRarity or itemQuality or 0 end if not itemData.class and itemType then itemData.class = itemType end if not itemData.subclass and itemSubType then itemData.subclass = itemSubType end if not itemData.name and itemName then itemData.name = itemName end + self.itemData = itemData end end elseif itemData then