diff --git a/components/home/HomeRows.bs b/components/home/HomeRows.bs index e748921a8..e2c583dc4 100644 --- a/components/home/HomeRows.bs +++ b/components/home/HomeRows.bs @@ -627,10 +627,15 @@ function getExpectedRowContribution(sectionName as string) as integer end if - if sectionName = "latestmedia" + if sectionName = "latestmedia" or sectionName = "recentlyreleased" if isMultiServerEnabled() sessions = getAllServerSessions() if sessions.Count() > 0 + ' Multi-server latest media builds 5 rows per server, while + ' recently released aggregates every server into a single row + if sectionName = "recentlyreleased" + return 1 + end if return sessions.Count() * 5 end if end if @@ -1129,19 +1134,46 @@ end sub ' createRecentlyReleasedRow: Creates a row displaying recently released items sorted by premiere date ' sub createRecentlyReleasedRow() - sectionName = tr("Recently Released") + ' create a Recently Added in row for each library + for each lib in m.filteredLatest + if not isStringEqual(lib.collectionType, "boxsets") and not isStringEqual(lib.collectionType, "livetv") and not isStringEqual(lib.json.CollectionType, "Program") + sectionName = `${tr("Recently Released in")} ${lib.name}` - if not sectionExists(sectionName) - recentlyReleasedRow = m.top.content.CreateChild("HomeRow") - recentlyReleasedRow.title = sectionName - recentlyReleasedRow.imageWidth = getPosterSize(false)[0] - recentlyReleasedRow.cursorSize = getPosterSize(false) - end if + ' Determine poster size based on content type and user preference + imagesize = getPosterSize(false) ' Default to portrait, but respect thumbnail toggle - ' Load the Recently Released Data (lazy task creation) - task = getOrCreateTask("recentlyReleased") - task.observeField("content", "updateRecentlyReleasedItems") - task.control = "RUN" + if isValid(lib.json.CollectionType) + if isStringEqual(lib.json.CollectionType, "movies") + imagesize = getPosterSize(false) ' Movies use portrait, or wide if thumbnails enabled + else if isStringEqual(lib.json.CollectionType, "music") + imagesize = homeRowItemSizes.MUSIC_ALBUM + end if + end if + + if not sectionExists(sectionName) + row = m.top.content.CreateChild("HomeRow") + row.title = sectionName + row.imageWidth = imagesize[0] + row.cursorSize = imagesize + end if + + try + loadLatest = createObject("roSGNode", "LoadItemsTask") + loadLatest.itemsToLoad = "recentlyReleased" + loadLatest.itemId = lib.id + + metadata = { "title": lib.name } + metadata.Append({ "contentType": lib.json.CollectionType }) + loadLatest.metadata = metadata + + loadLatest.observeField("content", "updateRecentlyReleasedItems") + loadLatest.control = TaskControl.RUN + catch e + removeHomeSection(sectionName) + m.global.sceneManager.callFunc("standardDialog", `Error creating Recently Released rows`, { data: ["

" + `Error Message: ${e.message}` + "

"] }) + end try + end if + end for end sub ' sectionExists: Checks if passed section exists in home row content @@ -2150,22 +2182,37 @@ end sub ' updateRecentlyReleasedItems: Processes LoadItemsTask content for recently released items ' -sub updateRecentlyReleasedItems() +' @param {dynamic} msg - LoadItemsTask +sub updateRecentlyReleasedItems(msg) m.processedRowCount++ - itemData = getTaskContentAndCleanup("recentlyReleased") + itemData = msg.GetData() - sectionName = tr("Recently Released") + node = msg.getRoSGNode() + node.unobserveField("content") + node.content = [] + + sectionName = tr("Recently Released in") + " " + node.metadata.title if not isValidAndNotEmpty(itemData) removeHomeSection(sectionName) return end if - ' Create row using the new data + imagesize = getPosterSize(false) + + if isValid(node.metadata.contentType) + if LCase(node.metadata.contentType) = "movies" + imagesize = getPosterSize(false) + else if LCase(node.metadata.contentType) = "music" + imagesize = homeRowItemSizes.MUSIC_ALBUM + end if + end if + + ' remake row using new data row = CreateObject("roSGNode", "HomeRow") row.title = sectionName - row.imageWidth = getPosterSize(false)[0] - row.cursorSize = getPosterSize(false) + row.imageWidth = imagesize[0] + row.cursorSize = imagesize row.usePoster = true for each item in itemData @@ -2174,15 +2221,14 @@ sub updateRecentlyReleasedItems() row.appendChild(item) end for - ' Row already exists, replace it with new content if sectionExists(sectionName) + ' Row already exists, replace it with new content m.top.content.replaceChild(row, getSectionIndex(sectionName)) setRowItemSize() return end if - ' Row does not exist, insert it after latest media - m.top.content.insertChild(row, getOriginalSectionIndex("latestmedia")) + m.top.content.insertChild(row, getOriginalSectionIndex("recentlyreleased")) setRowItemSize() end sub diff --git a/components/home/LoadItemsTask.bs b/components/home/LoadItemsTask.bs index b5705dde0..8d339d574 100644 --- a/components/home/LoadItemsTask.bs +++ b/components/home/LoadItemsTask.bs @@ -119,11 +119,12 @@ function loadRecentlyReleased() as object params = { userId: m.global.session.user.id, limit: 50, + parentId: m.top.itemId, recursive: true, fields: "PrimaryImageAspectRatio,Genres,Overview", enableImageTypes: `${ImageType.PRIMARY}, ${ImageType.BACKDROP}, ${ImageType.THUMB}`, imageTypeLimit: 1, - includeItemTypes: `${ItemType.MOVIE}, ${ItemType.SERIES}`, + includeItemTypes: `${ItemType.MOVIE}, ${ItemType.SERIES}, ${ItemType.BOOK}, ${ItemType.AUDIOBOOK}, ${ItemType.MUSICALBUM}`, sortBy: "PremiereDate,ProductionYear,SortName", sortOrder: "Descending", enableTotalRecordCount: false