Skip to content

Commit e90500d

Browse files
author
LocalIdentity
committed
Use last query for manually pasted strings
Can now properly search for items when the user pastes a weighted sum search
1 parent 4f77191 commit e90500d

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/Classes/TradeQuery.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,11 +1038,12 @@ function TradeQueryClass:PriceItemRowDisplay(row_idx, top_pane_alignment_ref, ro
10381038
controls["priceButton"..row_idx] = new("ButtonControl", { "TOPLEFT", controls["uri"..row_idx], "TOPRIGHT"}, {8, 0, 100, row_height}, "Price Item",
10391039
function()
10401040
controls["priceButton"..row_idx].label = "Searching..."
1041-
self.tradeQueryRequests:SearchWithURL(controls["uri"..row_idx].buf, function(items, errMsg)
1041+
self.tradeQueryRequests:SearchWithURL(controls["uri"..row_idx].buf, function(items, errMsg, query)
10421042
if errMsg then
10431043
self:SetNotice(controls.pbNotice, "Error: " .. errMsg)
10441044
else
10451045
self:SetNotice(controls.pbNotice, "")
1046+
self.lastQuery = query
10461047
self.resultTbl[row_idx] = items
10471048
self:UpdateControlsWithItems(row_idx)
10481049
end

src/Classes/TradeQueryRequests.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,15 @@ function TradeQueryRequestsClass:FetchResultBlock(url, callback)
302302
})
303303
end
304304

305-
---@param callback fun(items:table, errMsg:string)
305+
---@param callback fun(items:table, errMsg:string, query:string)
306306
function TradeQueryRequestsClass:SearchWithURL(url, callback)
307307
local subpath = url:match(self.hostName .. "trade/search/(.+)$")
308308
local paths = {}
309309
for path in subpath:gmatch("[^/]+") do
310310
table.insert(paths, path)
311311
end
312312
if #paths < 2 or #paths > 3 then
313-
return callback(nil, "Invalid URL")
313+
return callback(nil, "Invalid URL", nil)
314314
end
315315
local realm, league, queryId
316316
if #paths == 3 then
@@ -320,9 +320,11 @@ function TradeQueryRequestsClass:SearchWithURL(url, callback)
320320
queryId = paths[#paths]
321321
self:FetchSearchQueryHTML(realm, league, queryId, function(query, errMsg)
322322
if errMsg then
323-
return callback(nil, errMsg)
323+
return callback(nil, errMsg, nil)
324324
end
325-
self:SearchWithQuery(realm, league, query, callback)
325+
self:SearchWithQuery(realm, league, query, function(items, searchErrMsg)
326+
callback(items, searchErrMsg, query)
327+
end)
326328
end)
327329
end
328330

0 commit comments

Comments
 (0)