From eafad684b632ce8a56b35647f24cb09798cb0596 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 24 Feb 2024 11:40:52 -0500 Subject: [PATCH] Small improvement --- CHANGELOG.md | 4 ++- .../src/components/ContextMenu/ContextMenu.bs | 2 -- .../src/components/NavBar/IconButton.bs | 14 ++++----- .../components/PlaylistView/PlaylistView.bs | 29 +++++++++++++++---- .../components/PlaylistView/PlaylistView.xml | 1 + .../Services/LoungeService/LoungeService.bs | 2 -- .../src/components/VideoPlayer/VideoPlayer.bs | 1 + 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db71a384..55c44f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Added + +- Small improvement in the context menu of the Playlist view ## [0.20.1] - 2024-02-23 diff --git a/playlet-lib/src/components/ContextMenu/ContextMenu.bs b/playlet-lib/src/components/ContextMenu/ContextMenu.bs index 0a4b3921..8a055934 100644 --- a/playlet-lib/src/components/ContextMenu/ContextMenu.bs +++ b/playlet-lib/src/components/ContextMenu/ContextMenu.bs @@ -71,8 +71,6 @@ import "pkg:/source/utils/Types.bs" ' - "Remove group from Bookmarks" ' - "Reload bookmarks" - DONE ' -' TODO:P1 Playlist item seletected from the bookmarks need to play as a playlist, not as a single video -' TODO:P1 Context menu might need to be scrollable (both horizontally and vertically) ' TODO:P1 Context menu might need sections. Example: ' In a Channel view, while selecting a playlist: ' - Channel diff --git a/playlet-lib/src/components/NavBar/IconButton.bs b/playlet-lib/src/components/NavBar/IconButton.bs index d5c5341d..a122e397 100644 --- a/playlet-lib/src/components/NavBar/IconButton.bs +++ b/playlet-lib/src/components/NavBar/IconButton.bs @@ -1,4 +1,5 @@ import "pkg:/source/utils/Types.bs" +import "pkg:/source/utils/MathUtils.bs" ' Based on https://github.com/jellyfin/jellyfin-roku/blob/unstable/components/IconButton.brs function init() @@ -40,16 +41,11 @@ function setIconSize() height = m.top.height width = m.top.width if height > 0 and width > 0 - ' TODO: Use smallest number between them - m.buttonIcon.height = m.top.height + iconSize = MathUtils.Min(height, width) - m.top.padding + m.buttonIcon.height = iconSize + m.buttonIcon.width = iconSize - if m.top.padding > 0 - m.buttonIcon.height = m.buttonIcon.height - m.top.padding - end if - - m.buttonIcon.width = m.buttonIcon.height - - m.buttonIcon.translation = [((width - m.buttonIcon.width) / 2), ((height - m.buttonIcon.height) / 2)] + m.buttonIcon.translation = [((width - iconSize) / 2), ((height - iconSize) / 2)] m.buttonText.translation = [-5, height] m.buttonText.width = width + 10 end if diff --git a/playlet-lib/src/components/PlaylistView/PlaylistView.bs b/playlet-lib/src/components/PlaylistView/PlaylistView.bs index 258213fd..83255514 100644 --- a/playlet-lib/src/components/PlaylistView/PlaylistView.bs +++ b/playlet-lib/src/components/PlaylistView/PlaylistView.bs @@ -143,9 +143,6 @@ function OnItemLongPressed(index as integer) as void LogInfo("Long press: playlist:", playlistId, "video:", videoId) - ' TODO:P1 handle case of opening the channel - ' - Owner of a video - ' - Owner of a playlist contextMenuProviders = [m.top] ContextMenuUtils.Open(contextMenuProviders, m.appController, video) end function @@ -173,8 +170,20 @@ function GetContextMenuOptionsForItem(video as object) as object ContextMenuUtils.CreateOption("Queue video", m.videoQueue, "FuncAddToQueueVideo", [video]), ] - if not StringUtils.IsNullOrEmpty(playlist.authorId) - options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist])) + playlistAuthorId = playlist.authorId + videoAuthorId = video.authorId + + if not StringUtils.IsNullOrEmpty(playlistAuthorId) or not StringUtils.IsNullOrEmpty(videoAuthorId) + if playlistAuthorId = videoAuthorId + options.push(ContextMenuUtils.CreateOption("Open channel", m.top, "OpenPlaylistChannel", [playlist])) + else + if not StringUtils.IsNullOrEmpty(playlistAuthorId) + options.push(ContextMenuUtils.CreateOption("Open playlist channel", m.top, "OpenPlaylistChannel", [playlist])) + end if + if not StringUtils.IsNullOrEmpty(videoAuthorId) + options.push(ContextMenuUtils.CreateOption("Open video channel", m.top, "OpenVideoChannel", [video])) + end if + end if end if options.append(m.bookmarks@.GetMenuForPlaylist(playlist)) @@ -193,6 +202,16 @@ function OpenPlaylistChannel(playlist as object) as void ChannelUtils.Open(channel) end function +function OpenVideoChannel(video as object) as void + authorId = video.authorId + if StringUtils.IsNullOrEmpty(authorId) + LogWarn("Invalid authorId:", authorId) + return + end if + channel = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid) + ChannelUtils.Open(channel) +end function + 'TODO:P1 a playlist could have been opened from the bookmarks, which can be as old as 3 days ' We should make a request in this case, and let the cache handle freshness. function LoadPlaylistIfNeeded() as void diff --git a/playlet-lib/src/components/PlaylistView/PlaylistView.xml b/playlet-lib/src/components/PlaylistView/PlaylistView.xml index 7c4ba2b1..1b487089 100644 --- a/playlet-lib/src/components/PlaylistView/PlaylistView.xml +++ b/playlet-lib/src/components/PlaylistView/PlaylistView.xml @@ -6,6 +6,7 @@ +