Skip to content

Commit 9c68e2e

Browse files
committed
inline the idle callback
1 parent b51c086 commit 9c68e2e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lua/dyn_menu.lua

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,6 @@ local function menu_data_cb(name, items)
439439
send_ready_message()
440440
end
441441

442-
-- commit menu items if changed
443-
local function update_menu_items()
444-
if menu_items_dirty then
445-
mp.set_property_native(menu_prop, menu_items)
446-
menu_items_dirty = false
447-
end
448-
end
449-
450442
-- script message: get <keyword> <src>
451443
mp.register_script_message('get', function(keyword, src)
452444
if not src or src == '' then
@@ -491,8 +483,13 @@ mp.register_script_message('update', function(keyword, json)
491483
menu_items_dirty = true
492484
end)
493485

494-
-- update menu items when idle, this reduces the update frequency
495-
mp.register_idle(update_menu_items)
486+
-- commit menu items when idle, this reduces the update frequency
487+
mp.register_idle(function()
488+
if menu_items_dirty then
489+
mp.set_property_native(menu_prop, menu_items)
490+
menu_items_dirty = false
491+
end
492+
end)
496493

497494
-- parse menu data when menu items ready
498495
--

0 commit comments

Comments
 (0)