diff --git a/main/calendar-menu.lua b/main/calendar-menu.lua index af4f3b8..0fba9a1 100644 --- a/main/calendar-menu.lua +++ b/main/calendar-menu.lua @@ -21,6 +21,10 @@ function on_drawer_open() have_permission = true + if #events == #drawer:items() then + return + end + lines = map(events, function(it) local date = fmt.colored(os.date("%d.%m", it.begin), it.color) return date..fmt.space(4)..it.title diff --git a/main/contacts-menu.lua b/main/contacts-menu.lua index 36013e6..93d72b1 100644 --- a/main/contacts-menu.lua +++ b/main/contacts-menu.lua @@ -22,6 +22,10 @@ function on_drawer_open() sort_by_name(phone:contacts()) ) + if #contacts == #drawer:items() then + return + end + names = map(contacts, function(it) return it.name end) keys = map(contacts, function(it) return it.lookup_key end) diff --git a/samples/apps-menu.lua b/samples/apps-menu.lua new file mode 100644 index 0000000..536bdf0 --- /dev/null +++ b/samples/apps-menu.lua @@ -0,0 +1,26 @@ +-- name = "Apps menu" +-- type = "drawer" +-- testing = "true" + +function on_drawer_open() + apps_tab = apps:list() + debug:toast("called") + + -- Do not update if the list of the apps is not changed + if #apps_tab ~= #drawer:items() then + update() + end +end + +function update() + names_tab = map(function(it) return apps:name(it) end, apps_tab) + apps:request_icons(apps_tab) +end + +function on_icons_ready(icons_tab) + drawer:show_list(names_tab, icons_tab, nil, true) +end + +function on_click(idx) + apps:launch(apps_tab[idx]) +end