summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP Guerrero <jeanpatrick.guerrero@gmail.com>2018-04-27 22:55:30 +0200
committerJP Guerrero <jeanpatrick.guerrero@gmail.com>2018-04-27 23:01:03 +0200
commitd95cdee33d6565c255a1936a10fbb0290ab1e2e4 (patch)
tree03399628b958b6ba3c8108505342ba7acebb2f60
parentc630c9097004cd618d4aca08480f991b9ba6c4a9 (diff)
Cache results only if searched 2 times (to avoid silly searches)
-rw-r--r--init.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index aefecf7..6dcc789 100644
--- a/init.lua
+++ b/init.lua
@@ -343,8 +343,13 @@ function craftguide:get_filter_items(data, player)
if not data.items then
data.init_filter_items = filtered_list
end
- elseif filter ~= "" and not datas.searches[filter] then
- datas.searches[filter] = filtered_list
+ elseif filter ~= "" then
+ -- Cache the results only if searched 2 times
+ if datas.searches[filter] == nil then
+ datas.searches[filter] = false
+ else
+ datas.searches[filter] = filtered_list
+ end
end
data.items = filtered_list