Skip to content

Commit 29d745c

Browse files
committed
Fix empty results being shown and hide filters for uniques
1 parent e37d478 commit 29d745c

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

src/Classes/TradeQuery.lua

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,14 @@ function TradeQueryClass:UpdateDropdownList(row_idx)
841841
self.controls["resultDropdown".. row_idx].selIndex = 1
842842
self.controls["resultDropdown".. row_idx]:SetList(dropdownLabels)
843843
end
844+
function TradeQueryClass:ResetResultRow(rowIdx)
845+
self.itemIndexTbl[rowIdx] = nil
846+
self.sortedResultTbl[rowIdx] = nil
847+
self.resultTbl[rowIdx] = nil
848+
self.totalPrice[rowIdx] = nil
849+
self:UpdateDropdownList(rowIdx)
850+
self.controls.fullPrice.label = "^7Total Price: " .. self:GetTotalPriceString()
851+
end
844852
function TradeQueryClass:UpdateControlsWithItems(row_idx)
845853
local sortMode = self.itemSortSelectionList[self.pbItemSortSelectionIndex]
846854
local sortedItems, errMsg = self:SortFetchResults(row_idx, sortMode)
@@ -857,10 +865,7 @@ function TradeQueryClass:UpdateControlsWithItems(row_idx)
857865

858866
self.sortedResultTbl[row_idx] = sortedItems
859867
if not sortedItems[1] then
860-
self.itemIndexTbl[row_idx] = nil
861-
self.totalPrice[row_idx] = nil
862-
self.controls.fullPrice.label = "Total Price: " .. self:GetTotalPriceString()
863-
self:UpdateDropdownList(row_idx)
868+
self:ResetResultRow(row_idx)
864869
self:SetNotice(self.controls.pbNotice, "^4No compatible items found for this slot.")
865870
return
866871
end
@@ -1134,11 +1139,7 @@ you can add them, copy the link here, and press "Price Item" to evaluate the ite
11341139
return m_min(m_max(index or 1, 1), self.sortedResultTbl[row_idx] and #self.sortedResultTbl[row_idx] or 1)
11351140
end
11361141
controls["changeButton"..row_idx] = new("ButtonControl", { "LEFT", controls["name"..row_idx], "LEFT"}, {135 + 8, 0, 80, row_height}, "<< Search", function()
1137-
self.itemIndexTbl[row_idx] = nil
1138-
self.sortedResultTbl[row_idx] = nil
1139-
self.resultTbl[row_idx] = nil
1140-
self.totalPrice[row_idx] = nil
1141-
self.controls.fullPrice.label = "^7Total Price: " .. self:GetTotalPriceString()
1142+
self:ResetResultRow(row_idx)
11421143
end)
11431144
controls["changeButton"..row_idx].shown = function() return self.resultTbl[row_idx] end
11441145
controls["resultDropdown"..row_idx] = new("DropDownControl", { "TOPLEFT", controls["changeButton"..row_idx], "TOPRIGHT"}, {8, 0, 351, row_height}, {}, function(index)

src/Classes/TradeQueryGenerator.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ function TradeQueryGeneratorClass:FinishQuery()
991991
local selectedTradeType = self.tradeTypes[self.tradeTypeIndex]
992992
-- Generate trade query str and open in browser
993993
local filters = 0
994-
local requiredMods = self.calcContext.requiredMods
994+
local requiredMods = self.calcContext.requiredMods or {}
995995
local queryTable = {
996996
query = {
997997
filters = self.calcContext.special.queryFilters or {
@@ -1129,7 +1129,7 @@ function TradeQueryGeneratorClass:RequestQuery(slot, context, statWeights, callb
11291129

11301130
local controls = { }
11311131
local options = { }
1132-
local popupHeight = 110
1132+
local popupHeight = 80
11331133
local popupWidth = 400
11341134

11351135
local isJewelSlot = slot and slot.slotName:find("Jewel") ~= nil
@@ -1363,6 +1363,12 @@ Remove: anoints are completely ignored, and removed from items.]]
13631363
t_insert(mods, { label = modData.tradeMod.text, tradeId = modData.tradeMod.id })
13641364
end
13651365
end
1366+
if #mods == 1 then
1367+
main:OpenPopup(popupWidth, popupHeight, "Query Options", controls)
1368+
return
1369+
end
1370+
-- technically we could have 40, but the more we have the fewer stats fit in the weighted sum,
1371+
-- and this means a static popup size is ok
13661372
local maxSelectors = 3
13671373
-- set dropdown labels and adjust width
13681374
local function setModSelectors()

0 commit comments

Comments
 (0)