# HG changeset patch # User Matthew Wild # Date 1276262543 -7200 # Node ID 0d438a7ac4fcd5ee0c9390524df2b3dfb21156e6 # Parent b3a68e71b8a12ac11c3ff0d1455175278469f62b mod_adhoc: Scan through list of items on load, in case items have been added before we were loaded diff -r b3a68e71b8a1 -r 0d438a7ac4fc mod_adhoc/adhoc/mod_adhoc.lua --- a/mod_adhoc/adhoc/mod_adhoc.lua Thu Jun 10 22:32:49 2010 +0200 +++ b/mod_adhoc/adhoc/mod_adhoc.lua Fri Jun 11 15:22:23 2010 +0200 @@ -59,10 +59,19 @@ end end, 500); +local function handle_item_added(item) + commands[item.node] = item; +end + module:hook("item-added/adhoc", function (event) - commands[event.item.node] = event.item; + return handle_item_added(event.item); end, 500); module:hook("item-removed/adhoc", function (event) commands[event.item.node] = nil; end, 500); + +-- Pick up any items that are already added +for _, item in ipairs(module:get_host_items("adhoc")) do + handle_item_added(item); +end