From 3e8b01be937bfbf4e100c516372a0de9d6b7c91a Mon Sep 17 00:00:00 2001 From: kepler155c Date: Tue, 20 Feb 2018 23:59:33 -0500 Subject: [PATCH] 1.7.10 compatibility --- apis/chestAdapter.lua | 18 +++++++++--------- apps/chestManager.lua | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/apis/chestAdapter.lua b/apis/chestAdapter.lua index 76e5de8..bb55a25 100644 --- a/apis/chestAdapter.lua +++ b/apis/chestAdapter.lua @@ -77,9 +77,10 @@ function ChestAdapter:refresh(throttle) end -- provide a consolidated list of items -function ChestAdapter:listItems() +function ChestAdapter:listItems(throttle) local cache = { } local items = { } + throttle = throttle or Util.throttle() -- getAllStacks sometimes fails pcall(function() @@ -89,15 +90,14 @@ function ChestAdapter:listItems() local entry = cache[key] if not entry then - cache[key] = v - - if not itemDB:get(v) then - itemDB:add(v) - end - table.insert(items, v) - else - entry.count = entry.count + v.count + entry = itemDB:get(v) or itemDB:add(v) + entry = Util.shallowCopy(entry) + entry.count = 0 + cache[key] = entry + table.insert(items, entry) end + entry.count = entry.count + v.count + throttle() end itemDB:flush() end) diff --git a/apps/chestManager.lua b/apps/chestManager.lua index ecf89e6..99688d1 100644 --- a/apps/chestManager.lua +++ b/apps/chestManager.lua @@ -1091,6 +1091,7 @@ local function learnRecipe(page) listingPage:refresh() listingPage.grid:draw() + inventoryAdapter:eject(recipe, recipe.count, 'front') return true end else