[skip ci] fix bug where playlists will not load the second page when not logged in

This commit is contained in:
Brahim Hadriche committed 2025-06-18 11:29:55 -04:00
1 parent d70a07049a
commit a10f3df298
6 files changed
+66 -7

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Issue with deep linking not working due to session data race condition - Issue with deep linking not working due to session data race condition
- A bug where playlists will not load the second page when not logged in
### Changed ### Changed
@@ -17,6 +17,8 @@ end function
function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
if m.contentTask <> invalid if m.contentTask <> invalid
m.contentTask.cancel = true m.contentTask.cancel = true
m.contentTask = invalid
m.top.isLoading = false
end if end if
loadState = m.top.loadState loadState = m.top.loadState
@@ -30,10 +32,12 @@ function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
invidious: invidiousNode invidious: invidiousNode
singlePage: singlePage singlePage: singlePage
}, OnPlaylistContentTaskResult) }, OnPlaylistContentTaskResult)
m.top.isLoading = true
end function end function
function OnPlaylistContentTaskResult(output as object) as void function OnPlaylistContentTaskResult(output as object) as void
m.contentTask = invalid m.contentTask = invalid
m.top.isLoading = false
if output.cancelled if output.cancelled
return return
@@ -5,6 +5,8 @@
<field id="type" type="string" value="playlist" /> <field id="type" type="string" value="playlist" />
<field id="loadState" type="string" /> <field id="loadState" type="string" />
<!-- isLoading indicates if there's a background task running to fetch data -->
<field id="isLoading" type="boolean" />
<!-- index in a feed --> <!-- index in a feed -->
<field id="feedSourcesIndex" type="integer" value="-1" /> <field id="feedSourcesIndex" type="integer" value="-1" />
<field id="continuation" type="string" /> <field id="continuation" type="string" />
@@ -13,6 +13,11 @@ import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs" import "pkg:/source/utils/Types.bs"
function Init() function Init()
m.busySpinner = m.top.findNode("busySpinner")
m.busyspinner.poster.width = 100
m.busyspinner.poster.height = 100
m.busySpinner.poster.uri = "pkg:/images/spinner.png"
m.background = m.top.findNode("background") m.background = m.top.findNode("background")
m.backgroundSmall = m.top.findNode("backgroundSmall") m.backgroundSmall = m.top.findNode("backgroundSmall")
m.titleLabel = m.top.findNode("titleLabel") m.titleLabel = m.top.findNode("titleLabel")
@@ -69,6 +74,7 @@ function OnContentSet() as void
if itemFocused > -1 and content.getChildCount() > itemFocused if itemFocused > -1 and content.getChildCount() > itemFocused
m.list.jumpToItem = itemFocused m.list.jumpToItem = itemFocused
end if end if
m.top.isLoading = content.isLoading or content.loadState = FeedLoadState.Loading
LoadPlaylistIfNeeded() LoadPlaylistIfNeeded()
end function end function
@@ -249,3 +255,15 @@ function LoadPlaylistIfNeeded() as void
' TODO:P1 use a field instead of function call ' TODO:P1 use a field instead of function call
m.top.content@.LoadPlaylistPage(m.top.invidious) m.top.content@.LoadPlaylistPage(m.top.invidious)
end function end function
function OnLoadingChanged(event as object)
isLoading = event.GetData()
if isLoading
m.busyspinner.poster.rotation = 0
m.busySpinner.visible = true
m.busySpinner.control = "start"
else
m.busySpinner.visible = false
m.busySpinner.control = "stop"
end if
end function
@@ -1,6 +1,7 @@
<component name="PlaylistView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider"> <component name="PlaylistView" extends="Group" includes="AutoBind,Focus,ContextMenuProvider">
<interface> <interface>
<field id="content" type="node" onChange="OnContentSet" /> <field id="content" type="node" onChange="OnContentSet" />
<field id="isLoading" type="boolean" onChange="OnLoadingChanged" />
<field id="appController" type="node" bind="/AppController" /> <field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" /> <field id="invidious" type="node" bind="/Invidious" />
<field id="videoQueue" type="node" bind="/VideoQueue" /> <field id="videoQueue" type="node" bind="/VideoQueue" />
@@ -51,6 +52,12 @@
font="font:SmallestSystemFont" /> font="font:SmallestSystemFont" />
</LayoutGroup> </LayoutGroup>
<BusySpinner
id="busySpinner"
spinInterval="1"
translation="[45,620]"
visible="false" />
<MarkupGrid <MarkupGrid
id="list" id="list"
itemComponentName="PlaylistViewCell" itemComponentName="PlaylistViewCell"
@@ -88,6 +88,8 @@ namespace Innertube
"gridContinuation": ParseGridContinuation "gridContinuation": ParseGridContinuation
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation "tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
' Ignored nodes: ' Ignored nodes:
' When you mispell something in the search bar, this renderer shows
"didYouMeanRenderer": ParseNotImplemented
' A list of subscribers in a channel with a CTA to subscribe. ' A list of subscribers in a channel with a CTA to subscribe.
"recognitionShelfRenderer": ParseNotImplemented "recognitionShelfRenderer": ParseNotImplemented
' A playlist at the end of a video. We don't need that for now. ' A playlist at the end of a video. We don't need that for now.
@@ -1275,14 +1277,39 @@ namespace Innertube
end function end function
function ParseContinuationItemRenderer(nodeData as object, context as object) as object function ParseContinuationItemRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuationEndpoint", "continuationCommand", "token"]) ' In Playlists there are 2 continuation items:
if IsString(continuation) ' - The first one (innermost) we encounter is the continuation for the next page of videos
' In Playlists there are 2 continuation items, and one of them is useless... ' - The second one (outermost) is the continuation for recommended playlists
' TODO:P1 figure this out ' Because of that, we probably want to keep the first one.
if StringUtils.IsNullOrEmpty(context.currentFeed.continuation) ' We probably want to manage feeds properly and parse both at some point.
context.currentFeed.continuation = continuation if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
end if return invalid
end if end if
continuationEndpoint = nodeData["continuationEndpoint"]
if not IsAssociativeArray(continuationEndpoint)
return invalid
end if
continuation = ObjectUtils.Dig(continuationEndpoint, ["continuationCommand", "token"])
if IsString(continuation)
context.currentFeed.continuation = continuation
return invalid
end if
commands = ObjectUtils.Dig(continuationEndpoint, ["commandExecutorCommand", "commands"])
if not IsArray(commands)
return invalid
end if
for each command in commands
continuation = ObjectUtils.Dig(command, ["continuationCommand", "token"])
if IsString(continuation)
context.currentFeed.continuation = continuation
return invalid
end if
end for
return invalid return invalid
end function end function