Skip to content

Commit 6fff023

Browse files
committed
Update code docs
1 parent 87d2d33 commit 6fff023

5 files changed

Lines changed: 61 additions & 11 deletions

File tree

docs/components_ItemDetails.bs.html

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
m.loadFirstEpisodeTask = CreateObject("roSGNode", "LoadItemsTask")
7474
m.loadFirstEpisodeTask.itemsToLoad = "seriesFirstEpisode"
7575

76+
' Series: fetch the resume/next-up episode in the background for the Resume button
77+
m.loadSeriesResumeTask = CreateObject("roSGNode", "LoadItemsTask")
78+
m.loadSeriesResumeTask.itemsToLoad = "seriesResume"
79+
7680
' Season: fetch parent series metadata in the background for ratings/runtime/genres/logo
7781
m.loadSeasonSeriesTask = CreateObject("roSGNode", "LoadItemsTask")
7882
m.loadSeasonSeriesTask.itemsToLoad = "metaDataDetails"
@@ -175,7 +179,11 @@
175179
else
176180
m.buttonGrp.buttonFocused = 0
177181
end if
178-
focusButtonGroupChild()
182+
' Only move actual focus when the button group already owns it — avoid stealing
183+
' focus from the extras row or description when the button arrives asynchronously.
184+
if m.buttonGrp.isInFocusChain()
185+
focusButtonGroupChild()
186+
end if
179187
else
180188
' Resume button already present — update text and tick values
181189
resumeButton.text = resumeText
@@ -829,7 +837,18 @@
829837
manageGoToSeriesButton(item.type)
830838
manageDeleteButton()
831839

832-
' Season: kick off background fetch of parent series data for ratings/runtime/genres/logo
840+
' Series: kick off background fetch of resume/next-up episode for the Resume button
841+
if item.type = "Series"
842+
' Unobserve before re-observing to prevent callbacks stacking on repeated content changes.
843+
m.loadSeriesResumeTask.unobserveField("content")
844+
m.loadSeriesResumeTask.control = "STOP"
845+
m.top.nextUpEpisode = invalid
846+
m.loadSeriesResumeTask.itemId = item.id
847+
m.loadSeriesResumeTask.observeField("content", "onSeriesResumeLoaded")
848+
m.loadSeriesResumeTask.control = "RUN"
849+
end if
850+
851+
' Season: kick off background fetch of parent series metadata for ratings/runtime/genres/logo
833852
if item.type = "Season" and isValidAndNotEmpty(item.seriesId)
834853
' Unobserve before re-observing to prevent callbacks stacking on repeated content changes.
835854
m.loadSeasonSeriesTask.unobserveField("content")
@@ -1481,6 +1500,19 @@
14811500
end if
14821501
end sub
14831502

1503+
' onSeriesResumeLoaded: Set nextUpEpisode from seriesResume task result to show/hide the Resume button
1504+
sub onSeriesResumeLoaded()
1505+
m.loadSeriesResumeTask.unobserveField("content")
1506+
content = m.loadSeriesResumeTask.content
1507+
m.loadSeriesResumeTask.content = []
1508+
1509+
if isValid(content) and content.count() > 0
1510+
m.top.nextUpEpisode = content[0]
1511+
else
1512+
m.top.nextUpEpisode = invalid
1513+
end if
1514+
end sub
1515+
14841516
' onShuffleEpisodeDataLoaded: Play shuffled episodes for Series
14851517
sub onShuffleEpisodeDataLoaded()
14861518
m.getShuffleEpisodesTask.unobserveField("data")

docs/components_home_LoadItemsTask.bs.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,31 @@
242242
node = m.transformer.transformBaseItem(data.Items[0])
243243
if isValid(node) then results.push(node)
244244
end if
245+
else if m.top.itemsToLoad = "seriesResume"
246+
' For the series Resume button, prefer an in-progress (resumable) episode and fall back to the next unstarted episode.
247+
' Uses the same endpoint as the Continue Watching home row so the Resume button is consistent with it.
248+
resumeData = api.users.GetResumeItemsByQuery(globalUser.id, {
249+
ParentId: m.top.itemId,
250+
Filters: "IsResumable",
251+
SortBy: "DatePlayed",
252+
SortOrder: "Descending",
253+
Limit: 1,
254+
recursive: true,
255+
Fields: "PrimaryImageAspectRatio",
256+
EnableTotalRecordCount: false
257+
})
258+
if isValid(resumeData) and isValid(resumeData.Items) and resumeData.Items.Count() > 0
259+
node = m.transformer.transformBaseItem(resumeData.Items[0])
260+
if isValid(node) then results.push(node)
261+
else
262+
' No resumable episode — fall back to next unstarted episode.
263+
' DisableFirstEpisode: true so a Resume button never appears for a completely unwatched series.
264+
nextUpData = api.shows.GetNextUp({ UserId: globalUser.id, SeriesId: m.top.itemId, Limit: 1, DisableFirstEpisode: true, Fields: "PrimaryImageAspectRatio" })
265+
if isValid(nextUpData) and isValid(nextUpData.Items) and nextUpData.Items.Count() > 0
266+
node = m.transformer.transformBaseItem(nextUpData.Items[0])
267+
if isValid(node) then results.push(node)
268+
end if
269+
end if
245270
else if m.top.itemsToLoad = "metaData"
246271
results.push(ItemMetaData(m.top.itemId))
247272
else if m.top.itemsToLoad = "metaDataDetails"

docs/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/module-ItemDetails.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/source_ShowScenes.bs.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -676,13 +676,6 @@
676676
if isValid(trailerData)
677677
group.trailerAvailable = trailerData.Count() > 0
678678
end if
679-
else if item.type = "Series"
680-
' Load NextUp episode to decide whether to show the Resume button
681-
nextUpData = api.shows.GetNextUp({ UserId: m.global.user.id, SeriesId: item.id, Limit: 1, Fields: "PrimaryImageAspectRatio" })
682-
if isValid(nextUpData) and isValid(nextUpData.Items) and nextUpData.Items.Count() > 0
683-
transformer = JellyfinDataTransformer()
684-
group.nextUpEpisode = transformer.transformBaseItem(nextUpData.Items[0])
685-
end if
686679
end if
687680

688681
' Watch for button presses

0 commit comments

Comments
 (0)