diff options
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 46 |
1 files changed, 12 insertions, 34 deletions
@@ -341,22 +341,14 @@ local function favourites_group_menu_options(group) for _, id in ipairs(state.favourites) do local obj = catalogue:get(id) if obj then - local path = {} - local curr = obj - while curr.parent_id and curr.parent_id ~= 'root' and - catalogue:get(curr.parent_id) do - curr = catalogue:get(curr.parent_id) - path[#path+1] = curr - end - obj = util.copy_table(obj) add_programme(obj, time) local c = group_count(obj) if c then obj.info = tostring(c) end - if #path > 0 and curr.parent_id == 'root' then - util.reverse(path) + local path = catalogue:path_from_root(obj) + if path then obj.path = path end options[#options+1] = obj @@ -586,7 +578,7 @@ end local function goto_option() local menu = state:menu() local opt = menu.options[menu.cursor] - if not opt then + if not opt or not opt.path then return end @@ -599,34 +591,20 @@ local function goto_option() end end - if opt.path then - for i = 1, #opt.path do - cursor_to_object(opt.path[i].id) - push_group_menu(opt.path[i]) - end + for i = 1, #opt.path do + cursor_to_object(opt.path[i].id) + push_group_menu(opt.path[i]) end cursor_to_object(opt.id) + osd:dirty() end local function goto_playing() - if not state.playing_id then - return - end - - local obj = catalogue:get(state.playing_id) - if not obj then - return - end - - local path = {} - local curr = obj - while curr.parent_id and curr.parent_id ~= 'root' and - catalogue:get(curr.parent_id) do - curr = catalogue:get(curr.parent_id) - path[#path+1] = curr - end - if #path == 0 or curr.parent_id ~= 'root' then + local id = state.playing_id + local obj = id and catalogue:get(id) + local path = obj and catalogue:path_to_root(obj) + if not path then return end @@ -635,8 +613,8 @@ local function goto_playing() cursor_to_object(path[i].id) push_group_menu(path[i]) end + cursor_to_object(id) - cursor_to_object(obj.id) osd:dirty() end |
