diff options
| author | Sam <github@samlord.co.uk> | 2025-02-04 21:13:52 +0000 |
|---|---|---|
| committer | Sam <github@samlord.co.uk> | 2025-02-04 21:13:52 +0000 |
| commit | ff733e8f0c827e3d2d91bb7db29a85807867ab5e (patch) | |
| tree | ede269bca54b5316e5e0cd13eedde82d938b26dc /lua/playlist_browser.lua | |
| parent | 844b3f733ec30eff41c3b3d48c74561d7b11da8e (diff) | |
| download | tangara-fw-ff733e8f0c827e3d2d91bb7db29a85807867ab5e.tar.gz | |
Wrap filesystem iterator
Change to wrapping the filesystem iterator rather than iterating over
table values. Also centralise the is_playlist check and hide Playlists
menu if none are present
Diffstat (limited to 'lua/playlist_browser.lua')
| -rw-r--r-- | lua/playlist_browser.lua | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/lua/playlist_browser.lua b/lua/playlist_browser.lua index 4824b581..0339d59b 100644 --- a/lua/playlist_browser.lua +++ b/lua/playlist_browser.lua @@ -12,7 +12,7 @@ local font = require("font") local theme = require("theme") local playback = require("playback") local queue = require("queue") -local table_iterator = require("table_iterator") +local playlist_iterator = require("playlist_iterator") local img = require("images") @@ -60,11 +60,6 @@ return screen:new { } end - local is_playlist = function(item) - return item:filepath():match("%.playlist$") - or item:filepath():match("%.m3u8?$") - end - local get_icon_func = function(item) if item:is_directory() then return img.files @@ -73,16 +68,7 @@ return screen:new { end end - local playlists_and_dirs = {}; - for item in self.iterator do - if - is_playlist(item) or - item:is_directory() then - table.insert(playlists_and_dirs, item) - end - end - - widgets.InfiniteList(self.root, table_iterator:create(playlists_and_dirs), { + widgets.InfiniteList(self.root, playlist_iterator:create(self.iterator), { focus_first_item = true, get_icon = get_icon_func, callback = function(item) @@ -95,7 +81,7 @@ return screen:new { breadcrumb = item:filepath() }) elseif - is_playlist(item) then + playlist_iterator:is_playlist(item) then -- TODO: playlist viewer queue.open_playlist(item:filepath()) playback.playing:set(true) |
