From 63f8ba8617c40db460844e1edfc7b31346189c1c Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Fri, 20 Jun 2025 09:20:49 -0400 Subject: [PATCH] [skip ci] Small refactor --- playlet-lib/src/components/ChannelView/ChannelView.bs | 10 ++++------ .../src/components/ContentNode/ChannelContentNode.bs | 5 ++--- .../src/components/ContentNode/PlaylistContentNode.bs | 5 ++--- .../src/components/ContentNode/ProfileContentNode.bs | 5 ++--- .../components/Screens/RemoteScreen/RemoteScreen.bs | 5 ++--- .../components/Screens/SearchScreen/SearchScreen.bs | 5 ++--- .../src/components/Services/Innertube/Innertube.bs | 5 ++--- playlet-lib/src/components/VideoFeed/VideoRowList.bs | 4 ++-- playlet-lib/src/components/VideoPlayer/SponsorBlock.bs | 5 ++--- .../src/components/VideoPlayer/VideoContentTask.bs | 2 +- 10 files changed, 21 insertions(+), 30 deletions(-) diff --git a/playlet-lib/src/components/ChannelView/ChannelView.bs b/playlet-lib/src/components/ChannelView/ChannelView.bs index a93a3e19..c7ea5a3f 100644 --- a/playlet-lib/src/components/ChannelView/ChannelView.bs +++ b/playlet-lib/src/components/ChannelView/ChannelView.bs @@ -187,9 +187,8 @@ function OnSubscribeButtonSelected() subscribe: not m.top.isSubscribed } - callback = JobSystem.CreateCallback() - JobSystem.QueueJob(m.jobQueue, Jobs.SubscribeJob, input, callback) - m.subscribeJob = callback + m.subscribeJob = JobSystem.CreateCallback() + JobSystem.QueueJob(m.jobQueue, Jobs.SubscribeJob, input, m.subscribeJob) end function function OnBannerLoadStatus() as void @@ -407,9 +406,8 @@ function FetchSubscriptionStatus() as void invidious: m.invidious } - callback = JobSystem.CreateCallback(OnFetchSubscriptionStatusDone) - JobSystem.QueueJob(m.jobQueue, Jobs.FetchSubscriptionStatusJob, input, callback) - m.fetchSubscriptionStatusJob = callback + m.fetchSubscriptionStatusJob = JobSystem.CreateCallback(OnFetchSubscriptionStatusDone) + JobSystem.QueueJob(m.jobQueue, Jobs.FetchSubscriptionStatusJob, input, m.fetchSubscriptionStatusJob) end function function OnFetchSubscriptionStatusDone(event as object) as void diff --git a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs index 8b8c5608..f29eeb0b 100644 --- a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs +++ b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs @@ -23,9 +23,8 @@ function LoadChannel(invidiousNode as object, jobQueue as object) as void invidious: invidiousNode } - callback = JobSystem.CreateCallback(OnChannelContentJobDone) - JobSystem.QueueJob(jobQueue, Jobs.ChannelContentJob, input, callback) - m.channelContentJob = callback + m.channelContentJob = JobSystem.CreateCallback(OnChannelContentJobDone) + JobSystem.QueueJob(jobQueue, Jobs.ChannelContentJob, input, m.channelContentJob) end function function OnChannelContentJobDone(event as object) as void diff --git a/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs b/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs index 1980ad49..7c0fe488 100644 --- a/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs +++ b/playlet-lib/src/components/ContentNode/PlaylistContentNode.bs @@ -33,10 +33,9 @@ function LoadPlaylist(invidiousNode as object, jobQueue as object, singlePage as singlePage: singlePage } - callback = JobSystem.CreateCallback(OnPlaylistContentJobDone) - JobSystem.QueueJob(jobQueue, Jobs.PlaylistContentJob, input, callback) - m.playlistContentJob = callback m.top.isLoading = true + m.playlistContentJob = JobSystem.CreateCallback(OnPlaylistContentJobDone) + JobSystem.QueueJob(jobQueue, Jobs.PlaylistContentJob, input, m.playlistContentJob) end function function OnPlaylistContentJobDone(event as object) as void diff --git a/playlet-lib/src/components/ContentNode/ProfileContentNode.bs b/playlet-lib/src/components/ContentNode/ProfileContentNode.bs index e5a22211..92691dee 100644 --- a/playlet-lib/src/components/ContentNode/ProfileContentNode.bs +++ b/playlet-lib/src/components/ContentNode/ProfileContentNode.bs @@ -57,9 +57,8 @@ function RefreshAccessToken() as void } } - callback = JobSystem.CreateCallback(OnProfileRefreshTokenJobDone) - JobSystem.QueueJob(m.jobQueue, Jobs.ProfileRefreshTokenJob, input, callback) - m.profileRefreshTokenJob = callback + m.profileRefreshTokenJob = JobSystem.CreateCallback(OnProfileRefreshTokenJobDone) + JobSystem.QueueJob(m.jobQueue, Jobs.ProfileRefreshTokenJob, input, m.profileRefreshTokenJob) end function function OnProfileRefreshTokenJobDone(event as object) as void diff --git a/playlet-lib/src/components/Screens/RemoteScreen/RemoteScreen.bs b/playlet-lib/src/components/Screens/RemoteScreen/RemoteScreen.bs index e2370398..382bf3c6 100644 --- a/playlet-lib/src/components/Screens/RemoteScreen/RemoteScreen.bs +++ b/playlet-lib/src/components/Screens/RemoteScreen/RemoteScreen.bs @@ -188,9 +188,8 @@ function GeneratePairingCode() deviceId: m.loungeService.deviceId } - callback = JobSystem.CreateCallback(OnLoungeGenerateManualPairingCodeJobDone) - JobSystem.QueueJob(m.jobQueue, Jobs.LoungeGenerateManualPairingCodeJob, input, callback) - m.loungeGenerateManualPairingCodeJob = callback + m.loungeGenerateManualPairingCodeJob = JobSystem.CreateCallback(OnLoungeGenerateManualPairingCodeJobDone) + JobSystem.QueueJob(m.jobQueue, Jobs.LoungeGenerateManualPairingCodeJob, input, m.loungeGenerateManualPairingCodeJob) end function function OnLoungeGenerateManualPairingCodeJobDone(event as object) as void diff --git a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs index aa6e3886..cf134136 100644 --- a/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs +++ b/playlet-lib/src/components/Screens/SearchScreen/SearchScreen.bs @@ -111,9 +111,8 @@ function OnTextChange() as void "searchScreen": m.top } - callback = JobSystem.CreateCallback() - JobSystem.QueueJob(m.jobQueue, Jobs.SearchSuggestionsJob, input, callback) - m.searchSuggestionsJob = callback + m.searchSuggestionsJob = JobSystem.CreateCallback() + JobSystem.QueueJob(m.jobQueue, Jobs.SearchSuggestionsJob, input, m.searchSuggestionsJob) end function function OnSearchSuggestions(event as object) as void diff --git a/playlet-lib/src/components/Services/Innertube/Innertube.bs b/playlet-lib/src/components/Services/Innertube/Innertube.bs index 8b8bd54e..0ef74325 100644 --- a/playlet-lib/src/components/Services/Innertube/Innertube.bs +++ b/playlet-lib/src/components/Services/Innertube/Innertube.bs @@ -24,9 +24,8 @@ function OnRequestVisitorData() as void innertube: m.top } - callback = JobSystem.CreateCallback(OnInnertubeSessionDataJobDone) - JobSystem.QueueJob(m.top.jobQueue, Jobs.InnertubeSessionDataJob, input, callback) - m.innertubeSessionDataJob = callback + m.innertubeSessionDataJob = JobSystem.CreateCallback(OnInnertubeSessionDataJobDone) + JobSystem.QueueJob(m.top.jobQueue, Jobs.InnertubeSessionDataJob, input, m.innertubeSessionDataJob) end function function OnInnertubeSessionDataJobDone(event as object) as void diff --git a/playlet-lib/src/components/VideoFeed/VideoRowList.bs b/playlet-lib/src/components/VideoFeed/VideoRowList.bs index ea5fc8f6..9b1bb78f 100644 --- a/playlet-lib/src/components/VideoFeed/VideoRowList.bs +++ b/playlet-lib/src/components/VideoFeed/VideoRowList.bs @@ -228,8 +228,8 @@ function InitContent() as void } callback = JobSystem.CreateCallback(OnVideoRowListContentJobDone) - JobSystem.QueueJob(m.jobQueue, Jobs.VideoRowListContentJob, input, callback) m.pendingLoadJobs[callback.id] = { callback: callback } + JobSystem.QueueJob(m.jobQueue, Jobs.VideoRowListContentJob, input, callback) end function function CancelCurrentJobs() @@ -316,8 +316,8 @@ function LoadRowContent(contentNode as object) as void } callback = JobSystem.CreateCallback(OnVideoRowListRowContentJobDone) - JobSystem.QueueJob(m.jobQueue, Jobs.VideoRowListRowContentJob, input, callback) m.pendingLoadJobs[callback.id] = { callback: callback, content: contentNode } + JobSystem.QueueJob(m.jobQueue, Jobs.VideoRowListRowContentJob, input, callback) end function function OnVideoRowListRowContentJobDone(event as object) as void diff --git a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs index 54648ed9..5bcda2a3 100644 --- a/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs +++ b/playlet-lib/src/components/VideoPlayer/SponsorBlock.bs @@ -217,9 +217,8 @@ namespace SponsorBlock m.sponsorSkipEventJob.cancel = true end if - callback = JobSystem.CreateCallback() - JobSystem.QueueJob(m.jobQueue, Jobs.SponsorBlockSegmentViewedJob, { segmentId: segmentId }, callback) - m.sponsorSkipEventJob = callback + m.sponsorSkipEventJob = JobSystem.CreateCallback() + JobSystem.QueueJob(m.jobQueue, Jobs.SponsorBlockSegmentViewedJob, { segmentId: segmentId }, m.sponsorSkipEventJob) end function end namespace diff --git a/playlet-lib/src/components/VideoPlayer/VideoContentTask.bs b/playlet-lib/src/components/VideoPlayer/VideoContentTask.bs index 088c1d24..c4566e88 100644 --- a/playlet-lib/src/components/VideoPlayer/VideoContentTask.bs +++ b/playlet-lib/src/components/VideoPlayer/VideoContentTask.bs @@ -29,7 +29,7 @@ function VideoContentTask(input as object) as object messagePort = CreateObject("roMessagePort") MessagePortUtils.ObserveFieldScopedExSafe(innertubeNode, "visitorData", messagePort) innertubeNode.requestVisitorData = true - message = wait(10000, messagePort) + message = wait(20000, messagePort) innertubeNode.unobserveFieldScoped("visitorData") if message = invalid return {