Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Trader Changes from PoB 2 #8386

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 20 additions & 29 deletions src/Classes/TradeQuery.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ local TradeQueryClass = newClass("TradeQuery", function(self, itemsTab)
-- table holding all realm/league pairs. (allLeagues[realm] = [league.id,...])
self.allLeagues = {}
-- realm id-text table to pair realm name with API parameter
self.realmIds = {}

self.realmIds = {
["PC"] = "pc",
["Xbox"] = "xbox",
["Sony"] = "sony",
}
self.tradeQueryRequests = new("TradeQueryRequests")
main.onFrameFuncs["TradeQueryRequests"] = function()
self.tradeQueryRequests:ProcessQueue()
Expand Down Expand Up @@ -511,7 +514,7 @@ Highest Weight - Displays the order retrieved from trade]]
self.controls.updateCurrencyConversion = new("ButtonControl", {"BOTTOMLEFT", nil, "BOTTOMLEFT"}, {pane_margins_horizontal, -pane_margins_vertical, 240, row_height}, "Get Currency Conversion Rates", function()
self:PullPoENinjaCurrencyConversion(self.pbLeague)
end)
self.controls.pbNotice = new("LabelControl", {"BOTTOMRIGHT", nil, "BOTTOMRIGHT"}, {-row_height - pane_margins_vertical - row_vertical_padding, -pane_margins_vertical, 300, row_height}, "")
self.controls.pbNotice = new("LabelControl", {"BOTTOMRIGHT", nil, "BOTTOMRIGHT"}, {-row_height - pane_margins_vertical - row_vertical_padding, -pane_margins_vertical - row_height - row_vertical_padding, 300, row_height}, "")

-- used in PopupDialog:Draw()
local function scrollBarFunc()
Expand Down Expand Up @@ -1102,38 +1105,26 @@ function TradeQueryClass:UpdateRealms()
self.controls.realm:SetSel(self.pbRealmIndex)
end

if main.POESESSID and main.POESESSID ~= "" then
-- Fetch from trade page using POESESSID, includes private leagues
ConPrintf("Fetching realms and leagues using POESESSID")
self.tradeQueryRequests:FetchRealmsAndLeaguesHTML(function(data, errMsg)
-- use trade leagues api to get trade leagues including private leagues if valid.
for _, realmId in pairs (self.realmIds) do
self.tradeQueryRequests:FetchLeagues(realmId, function(leagues, errMsg)
if errMsg then
self:SetNotice(self.controls.pbNotice, "Error while fetching league list: "..errMsg)
return
self:SetNotice(self.controls.pbNotice, "Using Fallback Error while fetching league list: "..errMsg)
end
local leagues = data.leagues
self.allLeagues = {}
for _, value in ipairs(leagues) do
if not self.allLeagues[value.realm] then self.allLeagues[value.realm] = {} end
t_insert(self.allLeagues[value.realm], value.id)
end
self.realmIds = {}
for _, value in pairs(data.realms) do
-- filter out only Path of Exile one realms, as poe2 is not supported yet
if value.text:match("PoE 1 ") then
self.realmIds[value.text:gsub("PoE 1 ", "")] = value.id
end
for _, league in ipairs(leagues) do
if not self.allLeagues[realmId] then self.allLeagues[realmId] = {} end
t_insert(self.allLeagues[realmId], league)
end
setRealmDropList()

end)
else
-- Fallback to static list
ConPrintf("Using static realms list")
self.realmIds = {
["PC"] = "pc",
["PS4"] = "sony",
["Xbox"] = "xbox",
}
setRealmDropList()
end

-- perform a generic search to make sure POESESSID if valid.
self.tradeQueryRequests:PerformSearch("pc", "Standard", [[{"query":{"status":{"option":"online"},"stats":[{"type":"and","filters":[]}]},"sort":{"price":"asc"}}]], function(response, errMsg)
if errMsg then
self:SetNotice(self.controls.pbNotice, "Error: " .. tostring(errMsg))
end
end)
end
Loading
Loading