From 82a0d6862c4fd5a73c34e86eb72d07d6a53bb435 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 3 Jan 2026 22:59:13 -0800 Subject: fix sorting of resumed searches --- main.lua | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index e0f1f48..cb99d65 100644 --- a/main.lua +++ b/main.lua @@ -201,29 +201,6 @@ local function sort_options(options) end) end -local function toggle_menu_sort() - local menu = menus[depth] - - if not menu.sorted_options then - menu.orig_options = menu.options - menu.sorted_options = util.copy_table(menu.options) - sort_options(menu.sorted_options) - - if menu.search_options then - menu.orig_search_options = menu.search_options - menu.sorted_search_options = util.copy_table( - menu.search_options) - sort_options(menu.sorted_search_options) - end - end - - menu.sorted = not menu.sorted - menu.options = menu.sorted and menu.sorted_options or menu.orig_options - menu.search_options = menu.sorted and menu.sorted_search_options or - menu.orig_search_options - update_osd() -end - local function add_programme(opt, time) if opt.epg_channel_id then local prog = epg:scheduled_programme(opt.epg_channel_id, time) @@ -871,6 +848,27 @@ local function cancel_search() bind_menu_keys() end +local function toggle_menu_sort() + local menu = menus[depth] + local key = menu.type == 'search' and 'search_options' or 'options' + + if not menu['sorted_' .. key] then + menu['orig_' .. key] = menu[key] + menu['sorted_' .. key] = util.copy_table(menu[key]) + sort_options(menu['sorted_' .. key]) + end + + menu.sorted = not menu.sorted + menu[key] = menu.sorted and menu['sorted_' .. key] or + menu['orig_' .. key] + + if menu.type == 'search' then + update_search_matches() + else + update_osd() + end +end + local function bind_key(key, func, opts) -- unique name is needed for removal local i = #key_bindings+1 -- cgit v1.2.3-70-g09d2