Added a wrapper to make sure that the hooks work, and fail safely if not

Wobin [05-01-14 - 16:01]
Added a wrapper to make sure that the hooks work, and fail safely if not
Attempt refresh of scroll items on event of learning
Filename
Common.lua
SousChef.lua
TradingHouse.lua
diff --git a/Common.lua b/Common.lua
index 9d98538..dad482b 100644
--- a/Common.lua
+++ b/Common.lua
@@ -35,12 +35,15 @@ function SousChef.HookInventory()
 		local listView = v.listView
 		if listView and listView.dataTypes and listView.dataTypes[1] then
             SousChef.hookedFunctions = listView.dataTypes[1].setupCallback
-
-			listView.dataTypes[1].setupCallback =
-				function(rowControl, slot)
-                    SousChef.hookedFunctions(rowControl, slot)
-					SousChef.AddRankToSlot(rowControl)
-				end
+			if SousChef.hookedFunctions then
+				listView.dataTypes[1].setupCallback =
+					function(rowControl, slot)
+	                    SousChef.hookedFunctions(rowControl, slot)
+						SousChef.AddRankToSlot(rowControl)
+					end
+			else
+				d("SousChef could not hook into the Inventory")
+			end
 		end
     end

diff --git a/SousChef.lua b/SousChef.lua
index 0658649..31e880c 100644
--- a/SousChef.lua
+++ b/SousChef.lua
@@ -15,6 +15,10 @@ local u = SousChef.Utility

 local LAM = LibStub:GetLibrary("LibAddonMenu-1.0")

+local BACKPACK = ZO_PlayerInventoryBackpack
+local BANK = ZO_PlayerBankBackpack
+local GUILD_BANK = ZO_GuildBankBackpack
+
 SousChef.Pantry = {}
 SousChef.Cookbook = {}
 SousChef.ReverseCookbook = {}
@@ -67,6 +71,10 @@ function SousChef.ParseRecipes()

 		end
 	end
+	ZO_ScrollList_RefreshVisible(BACKPACK)
+	ZO_ScrollList_RefreshVisible(BANK)
+	ZO_ScrollList_RefreshVisible(GUILD_BANK)
+
 end

 local function SousChefCreateSettings()
diff --git a/TradingHouse.lua b/TradingHouse.lua
index 02b1402..cdd45d1 100644
--- a/TradingHouse.lua
+++ b/TradingHouse.lua
@@ -31,10 +31,14 @@ end

 function SousChef.HookTrading(...)
     if SousChef.hookedDataFunction then return end
-    SousChef.hookedDataFunction = ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback
-    ZO_TradingHouseItemPaneSearchResults.dataTypes[1].setupCallback = function(...)
-        local row, data = ...
-        SousChef.hookedDataFunction(...)
-        SousChef.AddTradingSlot(row, data)
+    SousChef.hookedDataFunction = TRADING_HOUSE.m_searchResultsList.dataTypes[1].setupCallback
+    if SousChef.hookedDataFunction then
+        TRADING_HOUSE.m_searchResultsList.dataTypes[1].setupCallback = function(...)
+            local row, data = ...
+            SousChef.hookedDataFunction(...)
+            SousChef.AddTradingSlot(row, data)
+        end
+    else
+        d("SousChef could not hook into the Trading House")
     end
 end
\ No newline at end of file