Skip to content

Commit eb58ba4

Browse files
committed
Fix league/realm selectors not rebuilding url and make them persistent
1 parent 78263d0 commit eb58ba4

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/Classes/CompareBuySimilar.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ function M.openPopup(item, slotName, primaryBuild)
334334

335335
-- Helper to fetch and populate leagues for a given realm API id
336336
local function fetchLeaguesForRealm(realmApiId)
337+
local lastIdx = M.lastLeagueIdx
337338
controls.leagueDrop:SetList({"Loading..."})
338339
controls.leagueDrop.selIndex = 1
339340
tradeQueryRequests:FetchLeagues(realmApiId, function(leagues, errMsg)
@@ -363,6 +364,9 @@ function M.openPopup(item, slotName, primaryBuild)
363364
break
364365
end
365366
end
367+
if lastIdx then
368+
controls.leagueDrop:SetSel(lastIdx)
369+
end
366370
end)
367371
end
368372

@@ -376,21 +380,30 @@ function M.openPopup(item, slotName, primaryBuild)
376380
local realmApiId = REALM_API_IDS[value] or "pc"
377381
fetchLeaguesForRealm(realmApiId)
378382
rebuildUrl()
383+
M.lastRealmIdx = index
379384
end)
385+
if M.lastRealmIdx then
386+
controls.realmDrop:SetSel(M.lastRealmIdx, true)
387+
end
380388

381389
-- League dropdown
382390
controls.leagueLabel = new("LabelControl", {"LEFT", controls.realmDrop, "RIGHT"}, {12, 0, 0, 16}, "^7League:")
383391
controls.leagueDrop = new("DropDownControl", {"LEFT", controls.leagueLabel, "RIGHT"}, {4, 0, 160, 20}, {"Loading..."}, function(index, value)
384392
-- League selection stored in the dropdown itself
385393
rebuildUrl()
394+
M.lastLeagueIdx = index
386395
end)
387396
controls.leagueDrop.enabled = function() return #controls.leagueDrop.list > 0 and controls.leagueDrop.list[1] ~= "Loading..." end
388397

389398
-- Listed status dropdown
390399
controls.listedDrop = new("DropDownControl", {"TOPRIGHT", nil, "TOPRIGHT"}, {-leftMargin, ctrlY, 242, 20}, LISTED_STATUS_LABELS, function(index, value)
391400
-- Listed status selection stored in the dropdown itself
392401
rebuildUrl()
402+
M.lastListedIndex = index
393403
end)
404+
if M.lastListedIndex then
405+
controls.listedDrop:SetSel(M.lastListedIndex, true)
406+
end
394407
controls.listedLabel = new("LabelControl", {"RIGHT", controls.listedDrop, "LEFT"}, {-4, 0, 0, 16}, "^7Listed:")
395408

396409
-- Fetch initial leagues for default realm

0 commit comments

Comments
 (0)