refactoring
This commit is contained in:
+23
-28
@@ -58,7 +58,7 @@ private.RESULTS, private.SAVED, private.FILTER = 1, 2, 3
|
|||||||
|
|
||||||
do
|
do
|
||||||
local searches = {}
|
local searches = {}
|
||||||
local search_index = 0
|
local search_index = 1
|
||||||
|
|
||||||
function private.current_search()
|
function private.current_search()
|
||||||
return searches[search_index]
|
return searches[search_index]
|
||||||
@@ -75,7 +75,7 @@ do
|
|||||||
searches[search_index].table:Show()
|
searches[search_index].table:Show()
|
||||||
|
|
||||||
m.search_box:SetText(searches[search_index].filter_string)
|
m.search_box:SetText(searches[search_index].filter_string)
|
||||||
if search_index <= 1 then
|
if search_index == 1 then
|
||||||
m.previous_button:Disable()
|
m.previous_button:Disable()
|
||||||
else
|
else
|
||||||
m.previous_button:Enable()
|
m.previous_button:Enable()
|
||||||
@@ -91,16 +91,7 @@ do
|
|||||||
m.update_continuation()
|
m.update_continuation()
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.new_search(filter_string, prettified)
|
function private.new_search(filter_string)
|
||||||
tinsert(aux_recent_searches, 1, {
|
|
||||||
filter_string = filter_string,
|
|
||||||
prettified = prettified,
|
|
||||||
})
|
|
||||||
while getn(aux_recent_searches) > 50 do
|
|
||||||
tremove(aux_recent_searches)
|
|
||||||
end
|
|
||||||
m.update_search_listings()
|
|
||||||
|
|
||||||
while getn(searches) > search_index do
|
while getn(searches) > search_index do
|
||||||
tremove(searches)
|
tremove(searches)
|
||||||
end
|
end
|
||||||
@@ -139,20 +130,6 @@ do
|
|||||||
m.update_search(search_index + 1)
|
m.update_search(search_index + 1)
|
||||||
m.update_tab(m.RESULTS)
|
m.update_tab(m.RESULTS)
|
||||||
end
|
end
|
||||||
|
|
||||||
function private.initialize_search_state()
|
|
||||||
searches[0] = {
|
|
||||||
placeholder = true,
|
|
||||||
table = m.tables[1],
|
|
||||||
status_bar = m.status_bars[1],
|
|
||||||
filter_string = ''
|
|
||||||
}
|
|
||||||
searches[0].table:SetDatabase({})
|
|
||||||
searches[0].status_bar:update_status(100, 100)
|
|
||||||
searches[0].status_bar:set_text('')
|
|
||||||
m.update_search(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.FRAMES(f)
|
function public.FRAMES(f)
|
||||||
@@ -163,7 +140,8 @@ function m.LOAD()
|
|||||||
m.create_frames(m, public, private)
|
m.create_frames(m, public, private)
|
||||||
m.update_tab(m.SAVED)
|
m.update_tab(m.SAVED)
|
||||||
m.update_auto_buy_filter()
|
m.update_auto_buy_filter()
|
||||||
m.initialize_search_state()
|
m.new_search('')
|
||||||
|
m.current_search().placeholder = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function public.OPEN()
|
function public.OPEN()
|
||||||
@@ -493,7 +471,13 @@ function public.execute(resume, real_time)
|
|||||||
m.current_search().table:SetSelectedRecord()
|
m.current_search().table:SetSelectedRecord()
|
||||||
else
|
else
|
||||||
if filter_string ~= m.current_search().filter_string or m.current_search().placeholder then
|
if filter_string ~= m.current_search().filter_string or m.current_search().placeholder then
|
||||||
m.new_search(filter_string, aux.util.join(aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
if m.current_search().placeholder then
|
||||||
|
m.current_search().filter_string = filter_string
|
||||||
|
m.current_search().placeholder = false
|
||||||
|
else
|
||||||
|
m.new_search(filter_string)
|
||||||
|
end
|
||||||
|
m.new_recent_search(filter_string, aux.util.join(aux.util.map(queries, function(filter) return filter.prettified end), ';'))
|
||||||
else
|
else
|
||||||
m.current_search().records = {}
|
m.current_search().records = {}
|
||||||
m.current_search().table:SetDatabase(m.current_search().records)
|
m.current_search().table:SetDatabase(m.current_search().records)
|
||||||
@@ -924,3 +908,14 @@ function private.update_filter_display()
|
|||||||
m.filter_display:SetText(aux.filter.indented_post_query_string(m.post_components))
|
m.filter_display:SetText(aux.filter.indented_post_query_string(m.post_components))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function private.new_recent_search(filter_string, prettified)
|
||||||
|
tinsert(aux_recent_searches, 1, {
|
||||||
|
filter_string = filter_string,
|
||||||
|
prettified = prettified,
|
||||||
|
})
|
||||||
|
while getn(aux_recent_searches) > 50 do
|
||||||
|
tremove(aux_recent_searches)
|
||||||
|
end
|
||||||
|
m.update_search_listings()
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ aux.search_tab.FRAMES(function(m, public, private)
|
|||||||
btn:SetScript('OnClick', function()
|
btn:SetScript('OnClick', function()
|
||||||
aux.scan.abort(m.search_scan_id)
|
aux.scan.abort(m.search_scan_id)
|
||||||
end)
|
end)
|
||||||
btn:Hide()
|
|
||||||
private.stop_button = btn
|
private.stop_button = btn
|
||||||
end
|
end
|
||||||
do
|
do
|
||||||
|
|||||||
Reference in New Issue
Block a user