Small improvement

This commit is contained in:
Brahim Hadriche committed 2024-02-24 11:40:52 -05:00
1 parent 14d3e38aeb
commit eafad684b6
7 files changed
+34 -19

No files matched your search

+3 -1
View File
@@ -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
@@ -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
@@ -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
@@ -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
@@ -6,6 +6,7 @@
<field id="videoQueue" type="node" bind="/VideoQueue" />
<field id="bookmarks" type="node" bind="/Bookmarks" />
<function name="OpenPlaylistChannel" />
<function name="OpenVideoChannel" />
</interface>
<children>
<Rectangle
@@ -1,7 +1,5 @@
import "pkg:/components/parts/AutoBind/OnNodeReadyNoOp.bs"
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
' TODO:P0
' 1. Add a section about the lounge in the privacy policy
function Init()
m.top.functionName = "LoungeServiceLoop"
@@ -50,6 +50,7 @@ function OnNodeReady()
m.fullScreenHint.translation = [0, minRect.height - m.fullScreenHint.height]
' TODO:P2 show a loading spinner if video is loading minimized
' Probably only worth doing after the video player is redone
m.top.enableUI = m.container.fullscreen
m.top.showFullScreenHint = not m.container.fullscreen