View Single Post
07/21/15, 02:55 PM   #10
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by merlight View Post
I have a question regarding bug #1 fix. You set .cached to false if .rawName doesn't match. Is that condition sufficient? I mean, I noticed the search also includes item style, e.g. "breton" finds all items in Breton style. Hopefully I can find a pair of identically named items in different styles to test. Just wanted to ask how much "wrong" it would be to clear the .cached flag unconditionally.
At the time I assumed two items with the same name would be the same style, but now that you mention it your probably right.

(untested) Probably the easiest way I can think of to fix that would be to copy the itemInstanceId and check it instead to see if its changed:
Lua Code:
  1. local function OnSlotUpdated(bagId, slotIndex, slotData)
  2.     if not slotData then return end
  3.     local searchData = slotData.searchData
  4.     if not (searchData and searchData.cached) then return end
  5.     if not (searchData.cache) then return end
  6.    
  7.     local newItemInstanceId = slotData.itemInstanceId
  8.     local oldItemInstaceId  = slotData.itemInstanceIdOLD
  9.    
  10.     -- if its the same item, nothing to do return.
  11.     -- if there is no item in the slot newItemInstanceId will be nil
  12.     if newItemInstanceId == oldItemInstaceId then return end
  13.    
  14.     searchData.cache = nil
  15.     searchData.cached = false
  16.    
  17.     -- if there is no item in the slot this will
  18.     -- nil out the old Id for us:
  19.     slotData.itemInstanceIdOLD = newItemInstanceId
  20. end
  Reply With Quote