@@ -330,14 +330,20 @@ function M.openPopup(item, slotName, primaryBuild)
330330 if not tradeQueryRequests then
331331 tradeQueryRequests = new (" TradeQueryRequests" )
332332 end
333+ local function rebuildUrl ()
334+ local result = buildURL (item , slotName , controls , modEntries , defenceEntries , isUnique )
335+ uri = result
336+ end
333337
334338 -- Helper to fetch and populate leagues for a given realm API id
335339 local function fetchLeaguesForRealm (realmApiId )
340+ local lastIdx = M .lastLeagueIdx
336341 controls .leagueDrop :SetList ({" Loading..." })
337342 controls .leagueDrop .selIndex = 1
338343 tradeQueryRequests :FetchLeagues (realmApiId , function (leagues , errMsg )
339344 if errMsg then
340345 controls .leagueDrop :SetList ({" Standard" })
346+ rebuildUrl ()
341347 return
342348 end
343349 local leagueList = {}
@@ -362,6 +368,10 @@ function M.openPopup(item, slotName, primaryBuild)
362368 break
363369 end
364370 end
371+ if lastIdx then
372+ controls .leagueDrop :SetSel (lastIdx )
373+ end
374+ rebuildUrl ()
365375 end )
366376 end
367377
@@ -370,31 +380,36 @@ function M.openPopup(item, slotName, primaryBuild)
370380 controls .realmDrop = new (" DropDownControl" , {" LEFT" , controls .realmLabel , " RIGHT" }, {4 , 0 , 80 , 20 }, {" PoE2" }, function (index , value )
371381 local realmApiId = REALM_API_IDS [value ] or " poe2"
372382 fetchLeaguesForRealm (realmApiId )
383+ rebuildUrl ()
384+ M .lastRealmIdx = index
373385 end )
386+ if M .lastRealmIdx then
387+ controls .realmDrop :SetSel (M .lastRealmIdx , true )
388+ end
374389 controls .realmDrop .disabled = true
375390
376391 -- League dropdown
377392 controls .leagueLabel = new (" LabelControl" , {" LEFT" , controls .realmDrop , " RIGHT" }, {12 , 0 , 0 , 16 }, " ^7League:" )
378393 controls .leagueDrop = new (" DropDownControl" , {" LEFT" , controls .leagueLabel , " RIGHT" }, {4 , 0 , 160 , 20 }, {" Loading..." }, function (index , value )
379- -- League selection stored in the dropdown itself
394+ M .lastLeagueIdx = index
395+ rebuildUrl ()
380396 end )
381397 controls .leagueDrop .enabled = function () return # controls .leagueDrop .list > 0 and controls .leagueDrop .list [1 ] ~= " Loading..." end
382398
383399 -- Listed status dropdown
384400 controls .listedDrop = new (" DropDownControl" , {" TOPRIGHT" , nil , " TOPRIGHT" }, {- leftMargin , ctrlY , 242 , 20 }, LISTED_STATUS_LABELS , function (index , value )
385- -- Listed status selection stored in the dropdown itself
401+ M .lastListedIndex = index
402+ rebuildUrl ()
386403 end )
404+ if M .lastListedIndex then
405+ controls .listedDrop :SetSel (M .lastListedIndex , true )
406+ end
387407 controls .listedLabel = new (" LabelControl" , {" RIGHT" , controls .listedDrop , " LEFT" }, {- 4 , 0 , 0 , 16 }, " ^7Listed:" )
388408
389- -- Fetch initial leagues for default realm
390- fetchLeaguesForRealm (" poe2" )
409+ -- Fetch initial leagues for the selected realm
410+ fetchLeaguesForRealm (REALM_API_IDS [ controls . realmDrop : GetSelValue ()] or " poe2" )
391411 ctrlY = ctrlY + rowHeight + 4
392412
393- local function rebuildUrl ()
394- local result = buildURL (item , slotName , controls , modEntries , defenceEntries , isUnique )
395- uri = result
396- end
397-
398413
399414 if isUnique then
400415 -- Unique item name label
@@ -483,8 +498,8 @@ function M.openPopup(item, slotName, primaryBuild)
483498 -- when the trade site has a dropdown for the value, we opt to disable
484499 -- the inputs as they are numeric
485500 if not (entry .isOption or entry .needsExactValue ) and entry .value then
486- controls [prefix .. " Min" ] = tradeHelpers .newPlainNumericEdit (nil , { minFieldX - popupWidth / 2 , controlYPos , fieldW , fieldH }, entry .value ~= 0 and tostring (entry .value ) or " " , " Min" , 8 , rebuildUrl )
487- controls [prefix .. " Max" ] = tradeHelpers .newPlainNumericEdit (nil , { maxFieldX - popupWidth / 2 , controlYPos , fieldW , fieldH }, " " , " Max" , 8 , rebuildUrl )
501+ controls [prefix .. " Min" ] = tradeHelpers .newPlainNumericEdit (nil , { minFieldX - popupWidth / 2 , controlYPos , fieldW , fieldH }, entry .value ~= 0 and tostring (entry .value ) or " " , " Min" , 8 , nil , rebuildUrl )
502+ controls [prefix .. " Max" ] = tradeHelpers .newPlainNumericEdit (nil , { maxFieldX - popupWidth / 2 , controlYPos , fieldW , fieldH }, " " , " Max" , 8 , nil , rebuildUrl )
488503 if not canSearch then
489504 controls [prefix .. " Min" ].enabled = function () return false end
490505 controls [prefix .. " Max" ].enabled = function () return false end
0 commit comments