Open views (#179)

* adjust todo

* Open view
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-10-24 17:21:48 -04:00
1 parent 8975861615
commit 549913ef7d
14 files changed
+129 -20

No files matched your search

@@ -47,7 +47,7 @@ namespace Http
' This is an endpoint allowing the web app to make an authenticated request
' without needing the Invidious token
' TODO:P2 this should be a POST request
' This is a GET not a POST for better caching
m.Get("/invidious/authenticated-request", function(context as object) as boolean
request = context.request
response = context.response
@@ -0,0 +1,44 @@
import "pkg:/components/ChannelView/ChannelUtils.bs"
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
import "pkg:/components/Services/Invidious/InvidiousToContentNode.bs"
namespace Http
class ViewRouter extends HttpRouter
function new()
super()
m.Get("/api/view/open", function(context as object) as boolean
request = context.request
response = context.response
appController = context.server.task.appController
playlistId = request.query.playlistId
authorId = request.query.authorId
if not StringUtils.IsNullOrEmpty(playlistId)
contentNode = InvidiousContent.ToPlaylistContentNode(invalid, { playlistId: playlistId }, invalid)
PlaylistUtils.Open(contentNode, appController)
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
VideoUtils.ToggleVideoPictureInPicture()
end if
response.Default(204, "OK")
else if not StringUtils.IsNullOrEmpty(authorId)
contentNode = InvidiousContent.ToChannelContentNode(invalid, { authorId: authorId }, invalid)
ChannelUtils.Open(contentNode, appController)
if VideoUtils.IsVideoPlayerOpen() and VideoUtils.IsVideoPlayerFullScreen()
VideoUtils.ToggleVideoPictureInPicture()
end if
response.Default(204, "OK")
else
response.Default(400, "Invalid request")
end if
return true
end function)
end function
end class
end namespace