local SousChef = SousChef
local u = SousChef.Utility
local m = SousChef.Media

function SousChef.AddTradingSlot(row, result)
	local rankIcon = SousChef.getIcon(row)

	rankIcon:SetHidden(true)
    if SousChef.settings.processRecipes then
        if u.MatchInIgnoreList(result.name) then return end
        if u.MatchesRecipe(result.name) then
            local match = u.MatchInCookbook(result.name)
            local gmatch = u.MatchInGlobalCookbook(result.name)
            if (match and SousChef.settings.checkKnown == "known") or
               (not match and SousChef.settings.checkKnown == "unknown")then
                rankIcon:SetDimensions(30, 30)
                rankIcon:SetAnchor(CENTER, row, CENTER, 230)
                rankIcon:SetTexture(m.CANLEARN)
                rankIcon:SetHidden(false)
                if not match and gmatch and SousChef.settings.checkKnown == "unknown" and SousChef.settings.markAlt then
                    rankIcon:SetColor(1,1,1,0.2)
                else
                    rankIcon:SetColor(1,1,1,1)
                end
            end
        end
    end
end



function SousChef.HookTrading(...)
    if SousChef.hookedDataFunction then return end
    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