Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion components/home/LoadItemsTask.bs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,52 @@ function loadRecentlyReleased() as object
return results
end function

' Reads a synced hidden-items map from settings. Keys are item or series ids,
' values are the ISO time each was hidden.
function getHiddenItemsMap(settingKey as string) as object
raw = m.global.session.user.settings[settingKey]
if not isValid(raw) or raw = "" then return {}
parsed = ParseJson(raw)
if not isValid(parsed) or Type(parsed) <> "roAssociativeArray" then return {}
return parsed
end function

' True when an item is hidden and has not been played since it was hidden.
' seriesOnly keys on the series id only, otherwise it falls back to the item id.
function isHiddenByMap(itemJson as object, hiddenMap as object, seriesOnly as boolean) as boolean
if hiddenMap.Count() = 0 or not isValid(itemJson) then return false

seriesId = itemJson.SeriesId
key = invalid
if isValid(seriesId) and seriesId <> ""
key = seriesId
else if not seriesOnly
key = itemJson.Id
end if
if not isValid(key) or key = "" then return false

hideTime = hiddenMap[key]
if not isValid(hideTime) then return false

userData = itemJson.UserData
if isValid(userData)
lastPlayed = userData.LastPlayedDate
if isValid(lastPlayed) and lastPlayed <> "" and lastPlayed > hideTime then return false
end if
return true
end function

function filterHiddenResults(results as object, hiddenMap as object, seriesOnly as boolean) as object
if hiddenMap.Count() = 0 then return results
filtered = []
for each entry in results
if not isHiddenByMap(entry.json, hiddenMap, seriesOnly)
filtered.push(entry)
end if
end for
return filtered
end function

function loadContinueWatching() as object
results = []

Expand Down Expand Up @@ -230,13 +276,16 @@ function loadContinueWatching() as object
results.push(tmp)
end for

return results
return filterHiddenResults(results, getHiddenItemsMap("ui.home.hiddenContinueWatchingItems"), false)
end function

' Load merged Continue Watching and Next Up items
function loadMergedContinueWatching() as object
results = []

hiddenCW = getHiddenItemsMap("ui.home.hiddenContinueWatchingItems")
hiddenNU = getHiddenItemsMap("ui.home.hiddenNextUpSeries")

' Load Continue Watching items
resumeParams = {
recursive: true,
Expand Down Expand Up @@ -280,6 +329,7 @@ function loadMergedContinueWatching() as object
' Add Continue Watching items first
if isChainValid(resumeData, "Items")
for each item in resumeData.Items
if isHiddenByMap(item, hiddenCW, false) then continue for
tmp = createSGNode("HomeData")
tmp.Id = item.LookupCI("Id")
tmp.name = item.LookupCI("name")
Expand Down Expand Up @@ -347,6 +397,7 @@ function loadMergedContinueWatching() as object
if userData["LastPlayedDate"] = invalid and isValid(seriesId)
userData["LastPlayedDate"] = seriesLastPlayedMap[seriesId]
end if
if isHiddenByMap(item, hiddenNU, true) then continue for
' Only add if not already in resume items
if not resumeItemIds.DoesExist(itemId)
tmp = createSGNode("HomeData")
Expand Down Expand Up @@ -770,6 +821,8 @@ end function
function loadNextUp() as object
results = []

hiddenNU = getHiddenItemsMap("ui.home.hiddenNextUpSeries")

params = {
recursive: true,
SortBy: "DatePlayed",
Expand Down Expand Up @@ -800,6 +853,7 @@ function loadNextUp() as object

if isChainValid(data, "Items")
for each item in data.Items
if isHiddenByMap(item, hiddenNU, true) then continue for
tmp = createSGNode("HomeData")
tmp.json = item
results.push(tmp)
Expand Down
4 changes: 3 additions & 1 deletion source/utils/settingsSync.bs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace settingsSync
{ pluginKey: "themeMusicEnabled", rokuKey: "playback.thememusic.enabled", type: "bool" },
{ pluginKey: "mdblistEnabled", rokuKey: "plugin.mdblist.enabled", type: "bool" },
{ pluginKey: "tmdbEpisodeRatingsEnabled", rokuKey: "plugin.tmdb.episodeRatings", type: "bool" },
{ pluginKey: "jellyseerrEnabled", rokuKey: "jellyseerr.enabled", type: "bool" }
{ pluginKey: "jellyseerrEnabled", rokuKey: "jellyseerr.enabled", type: "bool" },
{ pluginKey: "hiddenContinueWatchingItems", rokuKey: "ui.home.hiddenContinueWatchingItems", type: "direct" },
{ pluginKey: "hiddenNextUpSeries", rokuKey: "ui.home.hiddenNextUpSeries", type: "direct" }
]
end function

Expand Down