Skip to content

Commit

Permalink
Sort favorites to top of live tv schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
1hitsong committed Dec 1, 2024
1 parent 3d2b1df commit 0c50d23
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions components/liveTv/LoadChannelsTask.bs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "pkg:/source/api/baserequest.bs"
import "pkg:/source/api/sdk.bs"
import "pkg:/source/utils/config.bs"

sub init()
Expand All @@ -19,13 +20,14 @@ sub loadChannels()
end if

params = {
includeItemTypes: "LiveTvChannel",
SortBy: sort_field,
SortOrder: sort_order,
recursive: m.top.recursive,
UserId: m.global.session.user.id,
limit: m.top.limit,
startIndex: m.top.startIndex
startIndex: m.top.startIndex,
EnableFavoriteSorting: true,
EnableUserData: false,
AddCurrentProgram: false
}

' Handle special case when getting names starting with numeral
Expand All @@ -46,10 +48,7 @@ sub loadChannels()
params.append({ isFavorite: true })
end if

url = Substitute("Users/{0}/Items/", m.global.session.user.id)

resp = APIRequest(url, params)
data = getJson(resp)
data = api.liveTV.GetChannels(params)

if data.TotalRecordCount = invalid
m.top.channels = results
Expand All @@ -61,16 +60,7 @@ sub loadChannels()
for each item in data.Items
channel = createObject("roSGNode", "ChannelData")
channel.json = item
if item.UserData <> invalid and item.UserData.isFavorite <> invalid
channel.favorite = item.UserData.isFavorite
if channel.favorite = true
results.Unshift(channel)
else
results.push(channel)
end if
else
results.push(channel)
end if
results.push(channel)
end for
m.top.channels = results
end sub

0 comments on commit 0c50d23

Please sign in to comment.