View Single Post
04/08/15, 10:03 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Although the equipType would be the same since both items go in the same equip slot the itemStyles might not be the same, so that really needs to be updated also. You could just nil out the cache & set cached = false, like I did in my example above, but if you want to fix the cache instead of nilling it out the itemStyle needs to be updated as well:

Lua Code:
  1. local function OnSlotUpdated(bagId, slotIndex, slotData)
  2.   if slotData and slotData.searchData and slotData.searchData.cached and slotData.searchData.cache then
  3.     local name = GetItemName(bagId, slotIndex)
  4.     name = name:lower()
  5.    
  6.     if name ~= slotData.searchData.cache[1] then
  7.         local _, _, _, _, _, equipType, itemStyle = GetItemInfo(bagId, slotIndex)
  8.        
  9.         slotData.searchData.cache = {name, equipType, itemStyle}
  10.     end
  11.   end
  12. end
  13.  
  14. SHARED_INVENTORY:RegisterCallback("SlotUpdated", OnSlotUpdated)

Nilling it out would probably be the best solution though. Whenever a search is started it checks to see if data is cached and if its not it grabs that data on its own. That way it would only have to mess with those calls to update the cache if a search is being run instead of every time they don't match in the OnSlotUpdate.

Last edited by circonian : 04/08/15 at 10:06 PM.
  Reply With Quote