Skip to content

Commit f93e99e

Browse files
authored
PoB Trader: Fix issues caused by sorting mode change (#5552)
* fix(pobtrader): error message not clearing after successful sorting * fix(pobtrader): sort dropdown throwing error for jewels * fix(pobtrader): import button item tooltip not updating on sort * fix(pobtrader): check pseudoMods before indexing
1 parent d974e9d commit f93e99e

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src/Classes/TradeQuery.lua

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,21 @@ function TradeQueryClass:PriceItem()
217217
-- Row spacing reference is now the name, which is a smaller font than the total height
218218
local pane_height = (top_pane_alignment_height + row_height) * row_count - 4*row_count + 55
219219
local pane_width = 850
220-
local cnt = 1
220+
221+
local slotTables = {}
222+
for _, slotName in ipairs(baseSlots) do
223+
t_insert(slotTables, {name = slotName})
224+
end
225+
local activeSocketList = { }
226+
for nodeId, slot in pairs(self.itemsTab.sockets) do
227+
if not slot.inactive then
228+
t_insert(activeSocketList, nodeId)
229+
end
230+
end
231+
table.sort(activeSocketList)
232+
for _, nodeId in ipairs(activeSocketList) do
233+
t_insert(slotTables, {name = self.itemsTab.sockets[nodeId].label, ref = nodeId})
234+
end
221235

222236
local newItemList = { }
223237
for index, itemSetId in ipairs(self.itemsTab.itemSetOrderList) do
@@ -282,7 +296,7 @@ on trade site to work on other leagues and realms)]]
282296
self.controls.itemSortSelection = new("DropDownControl", {"TOPRIGHT", nil, "TOPRIGHT"}, -12, 19, 100, 18, self.sortSelectionList, function(index, value)
283297
self.pbSortSelectionIndex = index
284298
for index, _ in pairs(self.resultTbl) do
285-
self:UpdateControlsWithItems({name = baseSlots[index]}, index)
299+
self:UpdateControlsWithItems(slotTables[index], index)
286300
end
287301
end)
288302
self.controls.itemSortSelection.tooltipText = "Weighted Sum searches will always sort\nusing descending weighted sum."
@@ -362,25 +376,11 @@ on trade site to work on other leagues and realms)]]
362376
if self.pbRealm == "" then
363377
self:UpdateRealms()
364378
end
365-
366379
-- Individual slot rows
367380
top_pane_alignment_ref = {"TOPLEFT", self.controls.poesessidButton, "BOTTOMLEFT"}
368-
for _, slotName in ipairs(baseSlots) do
369-
self:PriceItemRowDisplay(cnt, {name = slotName}, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
370-
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..cnt], "BOTTOMLEFT"}
371-
cnt = cnt + 1
372-
end
373-
local activeSocketList = { }
374-
for nodeId, slot in pairs(self.itemsTab.sockets) do
375-
if not slot.inactive then
376-
t_insert(activeSocketList, nodeId)
377-
end
378-
end
379-
table.sort(activeSocketList)
380-
for _, nodeId in pairs(activeSocketList) do
381-
self:PriceItemRowDisplay(cnt, {name = self.itemsTab.sockets[nodeId].label, ref = nodeId}, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
382-
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..cnt], "BOTTOMLEFT"}
383-
cnt = cnt + 1
381+
for index, slotTbl in pairs(slotTables) do
382+
self:PriceItemRowDisplay(index, slotTbl, top_pane_alignment_ref, top_pane_alignment_width, top_pane_alignment_height, row_height)
383+
top_pane_alignment_ref = {"TOPLEFT", self.controls["name"..index], "BOTTOMLEFT"}
384384
end
385385
self.controls.fullPrice = new("LabelControl", nil, -3, pane_height - 58, pane_width - 256, row_height, "")
386386
self.controls.close = new("ButtonControl", nil, 0, pane_height - 30, 90, row_height, "Done", function()
@@ -464,13 +464,15 @@ function TradeQueryClass:UpdateControlsWithItems(slotTbl, index)
464464
if errMsg == "MissingConversionRates" then
465465
self:SetNotice(self.controls.pbNotice, "^4Price sorting is not available, falling back to DPS sort.")
466466
sortedItems, errMsg = self:SortFetchResults(slotTbl, index, self.sortModes.DPS)
467-
end
468-
if errMsg then
467+
elseif errMsg then
469468
self:SetNotice(self.controls.pbNotice, "Error: " .. errMsg)
470469
return
470+
else
471+
self:SetNotice(self.controls.pbNotice, "")
471472
end
473+
472474
self.sortedResultTbl[index] = sortedItems
473-
self.itemIndexTbl[index] = 1
475+
self.itemIndexTbl[index] = self.sortedResultTbl[index][1].index
474476
self.controls["priceButton"..index].tooltipText = "Sorted by " .. self.sortSelectionList[self.pbSortSelectionIndex]
475477
local pb_index = self.sortedResultTbl[index][1].index
476478
self.totalPrice[index] = {

src/Classes/TradeQueryRequests.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function TradeQueryRequestsClass:FetchResultBlock(url, callback)
262262
currency = trade_entry.listing.price.currency,
263263
item_string = common.base64.decode(trade_entry.item.extended.text),
264264
whisper = trade_entry.listing.whisper,
265-
weight = trade_entry.item.pseudoMods[1]:match("Sum: (.+)"),
265+
weight = trade_entry.item.pseudoMods and trade_entry.item.pseudoMods[1]:match("Sum: (.+)"),
266266
id = trade_entry.id
267267
})
268268
end

0 commit comments

Comments
 (0)