diff --git a/apps/Network.lua b/apps/Network.lua index 155ca0d..ee5940e 100644 --- a/apps/Network.lua +++ b/apps/Network.lua @@ -78,7 +78,7 @@ function page:eventHandler(event) title = t.label, }) elseif event.type == 'trust' then - shell.run('trust ' .. t.id) + shell.openTab('trust ' .. t.id) elseif event.type == 'reboot' then sendCommand(t.id, 'reboot') elseif event.type == 'shutdown' then diff --git a/apps/storageActivity.lua b/apps/storageActivity.lua index 31fdd9c..eec61be 100644 --- a/apps/storageActivity.lua +++ b/apps/storageActivity.lua @@ -100,7 +100,11 @@ function changedPage:eventHandler(event) return true end - + +local function uniqueKey(item) + return table.concat({ item.name, item.damage, item.nbtHash }, ':') +end + function changedPage:refresh() local t = storage:listItems('all') @@ -122,8 +126,7 @@ function changedPage:refresh() for _,v in pairs(self.lastItems) do found = false for k2,v2 in pairs(t) do - if v.id == v2.id and - v.dmg == v2.dmg then + if uniqueKey(v) == uniqueKey(v2) then if v.qty ~= v2.qty then local c = Util.shallowCopy(v2) c.lastQty = v.qty diff --git a/sys/apis/refinedProvider.lua b/sys/apis/refinedProvider.lua index 2c3a83e..1434803 100644 --- a/sys/apis/refinedProvider.lua +++ b/sys/apis/refinedProvider.lua @@ -5,14 +5,12 @@ local TableDB = require('tableDB') local RefinedProvider = class() local keys = { - 'fields', 'damage', 'displayName', 'maxCount', 'maxDamage', 'name', 'nbtHash', - 'rawName', } function RefinedProvider:init(args) @@ -78,6 +76,8 @@ function RefinedProvider:getCachedItemDetails(item) detail = t self.itemInfoDB:add(key, detail) + + os.sleep(0) -- prevent timeout on large inventories end end if detail then @@ -94,6 +94,9 @@ function RefinedProvider:listItems() end) if list then + + local throttle = Util.throttle() + for _,v in pairs(list) do local item = self:getCachedItemDetails(v) if item then @@ -103,6 +106,7 @@ function RefinedProvider:listItems() item.qty = v.count table.insert(items, item) end + throttle() end self.itemInfoDB:flush() end diff --git a/sys/apis/util.lua b/sys/apis/util.lua index d04be0f..387ca28 100644 --- a/sys/apis/util.lua +++ b/sys/apis/util.lua @@ -21,6 +21,17 @@ function Util.tryTimes(attempts, f, ...) return unpack(result) end +function Util.throttle() + local ts = os.time() + return function() + local nts = os.time() + if nts ~= ts then + ts = nts + os.sleep(0) + end + end +end + function Util.tostring(pattern, ...) local function serialize(tbl, width)