diff --git a/item_search_frame.lua b/item_search_frame.lua index b353ef6..0db6729 100644 --- a/item_search_frame.lua +++ b/item_search_frame.lua @@ -548,31 +548,20 @@ function public.start_search() refresh = true local item_id = private.item_id - local item_info = Aux.static.item_info(item_id) --- local class_index = Aux.item_class_index(item_info.class) --- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed - - local query = { - type = 'list', - start_page = AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(), - next_page = function(page, total_pages) + local query = Aux.scan_util.create_item_query( + item_id, + 'list', + AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() and 0 or AuxItemSearchFrameItemPageEditBox:GetNumber(), + function(page, total_pages) if AuxItemSearchFrameItemAllPagesCheckButton:GetChecked() then local last_page = max(total_pages - 1, 0) if page < last_page then return page + 1 end end - end, - name = item_info.name, - min_level = item_info.level, - min_level = item_info.level, - slot = item_info.slot, - class = Aux.item_class_index(item_info.class), - subclass = item_info.subclass, - quality = item_info.quality, - usable = item_info.usable, - } + end + ) Aux.scan.start{ queries = { query }, diff --git a/post_frame.lua b/post_frame.lua index cb65079..2fdc352 100644 --- a/post_frame.lua +++ b/post_frame.lua @@ -618,32 +618,20 @@ function private.refresh_entries() if selected_item then local item_id, suffix_id = selected_item.item_id, selected_item.suffix_id local item_key = item_id..':'..suffix_id - local item_info = Aux.info.item(item_id, suffix_id) existing_auctions[item_key] = nil - - local class_index = Aux.item_class_index(item_info.class) - local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) - - local query = { - type = 'list', - start_page = 0, - next_page = function(page, total_pages) + local query = Aux.scan_util.create_item_query( + item_id, + 'list', + 0, + function(page, total_pages) local last_page = max(total_pages - 1, 0) if page < last_page then return page + 1 end - end, - name = Aux.info.item(item_id).name, -- blizzard doesn't support queries with name suffixes - min_level = item_info.level, - min_level = item_info.level, - slot = item_info.slot, - class = class_index, - subclass = subclass_index, - quality = item_info.quality, - usable = item_info.usable, - } + end + ) private.status_bar:update_status(0,0) private.status_bar:set_text('Scanning auctions...') diff --git a/scan_util.lua b/scan_util.lua index 010232c..98621e5 100644 --- a/scan_util.lua +++ b/scan_util.lua @@ -11,7 +11,6 @@ function m.find(test, query, page, status_bar, on_failure, on_success) local pages = page > 0 and { page, page - 1 } or { page } query = Aux.util.copy_table(query) - query.page = page query.next_page = function() if getn(pages) == 1 then status_bar:update_status(50, 50) @@ -42,4 +41,27 @@ function m.find(test, query, page, status_bar, on_failure, on_success) end, } end) +end + +function m.create_item_query(item_id, type, start_page, next_page) + local item_info = Aux.static.item_info(item_id) + +-- local class_index = Aux.item_class_index(item_info.class) +-- local subclass_index = class_index and Aux.item_subclass_index(class_index, item_info.subclass) -- TODO test if needed + + return item_info and { + type = type, + start_page = start_page, + next_page = next_page, + name = item_info.name, + min_level = item_info.level, + min_level = item_info.level, + slot = item_info.slot, +-- class = class_index, +-- subclass = subclass_index, +-- class = Aux.item_class_index(item_info.class), +-- subclass = item_info.subclass, + quality = item_info.quality, + usable = item_info.usable, + } end \ No newline at end of file