[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
- 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
@@ -17,6 +17,8 @@ end function
function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
if m.contentTask <> invalid
m.contentTask.cancel = true
m.contentTask = invalid
m.top.isLoading = false
end if
loadState = m.top.loadState
@@ -30,10 +32,12 @@ function LoadPlaylist(invidiousNode as object, singlePage as boolean) as void
invidious: invidiousNode
singlePage: singlePage
}, OnPlaylistContentTaskResult)
m.top.isLoading = true
end function
function OnPlaylistContentTaskResult(output as object) as void
m.contentTask = invalid
m.top.isLoading = false
if output.cancelled
return
@@ -5,6 +5,8 @@
<field id="type" type="string" value="playlist" />
<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 -->
<field id="feedSourcesIndex" type="integer" value="-1" />
<field id="continuation" type="string" />
@@ -13,6 +13,11 @@ import "pkg:/source/utils/StringUtils.bs"
import "pkg:/source/utils/Types.bs"
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.backgroundSmall = m.top.findNode("backgroundSmall")
m.titleLabel = m.top.findNode("titleLabel")
@@ -69,6 +74,7 @@ function OnContentSet() as void
if itemFocused > -1 and content.getChildCount() > itemFocused
m.list.jumpToItem = itemFocused
end if
m.top.isLoading = content.isLoading or content.loadState = FeedLoadState.Loading
LoadPlaylistIfNeeded()
end function
@@ -249,3 +255,15 @@ function LoadPlaylistIfNeeded() as void
' TODO:P1 use a field instead of function call
m.top.content@.LoadPlaylistPage(m.top.invidious)
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">
<interface>
<field id="content" type="node" onChange="OnContentSet" />
<field id="isLoading" type="boolean" onChange="OnLoadingChanged" />
<field id="appController" type="node" bind="/AppController" />
<field id="invidious" type="node" bind="/Invidious" />
<field id="videoQueue" type="node" bind="/VideoQueue" />
@@ -51,6 +52,12 @@
font="font:SmallestSystemFont" />
</LayoutGroup>
<BusySpinner
id="busySpinner"
spinInterval="1"
translation="[45,620]"
visible="false" />
<MarkupGrid
id="list"
itemComponentName="PlaylistViewCell"
@@ -88,6 +88,8 @@ namespace Innertube
"gridContinuation": ParseGridContinuation
"tvSurfaceContentContinuation": ParseTvSurfaceContentContinuation
' 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.
"recognitionShelfRenderer": ParseNotImplemented
' A playlist at the end of a video. We don't need that for now.
@@ -1275,14 +1277,39 @@ namespace Innertube
end function
function ParseContinuationItemRenderer(nodeData as object, context as object) as object
continuation = ObjectUtils.Dig(nodeData, ["continuationEndpoint", "continuationCommand", "token"])
if IsString(continuation)
' In Playlists there are 2 continuation items, and one of them is useless...
' TODO:P1 figure this out
if StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
context.currentFeed.continuation = continuation
end if
' In Playlists there are 2 continuation items:
' - The first one (innermost) we encounter is the continuation for the next page of videos
' - The second one (outermost) is the continuation for recommended playlists
' Because of that, we probably want to keep the first one.
' We probably want to manage feeds properly and parse both at some point.
if not StringUtils.IsNullOrEmpty(context.currentFeed.continuation)
return invalid
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
end function