diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc0ccf82..054d5588 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Added
+
+- Playlists, streams, podcasts and related channels to Channel UI
+ - Pagination supported
+- Channels show up in web app (but no UI for channel details yet)
+
### Fixed
- Another bug where the app crashes if an error happens loading channel info
diff --git a/playlet-lib/src/components/ChannelView/ChannelView.bs b/playlet-lib/src/components/ChannelView/ChannelView.bs
index 64b26dc9..7fa03d4a 100644
--- a/playlet-lib/src/components/ChannelView/ChannelView.bs
+++ b/playlet-lib/src/components/ChannelView/ChannelView.bs
@@ -3,12 +3,19 @@ import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/StringUtils.bs"
function Init()
+ m.container = m.top.findNode("container")
+ m.scrollAnimation = m.top.findNode("scrollAnimation")
+ m.scrollAnimationInterpolator = m.scrollAnimation.findNode("scrollAnimationInterpolator")
+
m.banner = m.top.findNode("banner")
m.thumbnail = m.top.findNode("thumbnail")
m.authorLabel = m.top.findNode("authorLabel")
m.rowList = m.top.FindNode("rowList")
m.banner.ObserveField("loadStatus", FuncName(OnBannerLoadStatus))
+ m.authorId = ""
+
+ InitializeTabs()
end function
function OnNodeready()
@@ -42,9 +49,28 @@ function OnContentSet() as void
end if
end if
- m.rowList.content = content
-
content@.LoadChannel(m.invidious)
+
+ authorId = ValidString(content.authorId)
+ if authorId <> m.authorId and IsArray(content.tabs)
+ m.authorId = authorId
+ m.rowList.contentData = CreateChannelFeeds(m.authorId, content.tabs)
+ end if
+end function
+
+function CreateChannelFeeds(authorId as string, tabs as object) as object
+ if authorId = ""
+ return invalid
+ end if
+
+ feeds = []
+ for i = 0 to tabs.count() - 1
+ tabName = tabs[i]
+ if m.tabs.DoesExist(tabName)
+ feeds.Push(m.tabs[tabName](authorId))
+ end if
+ end for
+ return feeds
end function
function OnkeyEvent(key as string, press as boolean) as boolean
@@ -71,4 +97,47 @@ function OnBannerLoadStatus() as void
aspect = m.banner.bitmapWidth / m.banner.bitmapHeight
m.banner.height = m.banner.width / aspect
+ m.banner.translation = [0, -m.banner.height]
+ m.banner.visible = true
+
+ startPos = [0, 0]
+ endPos = [0, m.banner.height]
+ midPos = [0, m.banner.height / 2]
+
+ m.scrollAnimationInterpolator.keyValue = [startPos, midPos, endPos]
+ m.scrollAnimation.control = "start"
+end function
+
+function InitializeTabs()
+ m.tabs = {
+ videos: function(authorId as string) as object
+ return CreateChannelFeed("Latest videos", "channel_videos", authorId)
+ end function,
+ shorts: function(authorId as string) as object
+ return CreateChannelFeed("Shorts", "channel_shorts", authorId)
+ end function,
+ streams: function(authorId as string) as object
+ return CreateChannelFeed("Live", "channel_streams", authorId)
+ end function,
+ podcasts: function(authorId as string) as object
+ return CreateChannelFeed("Podcasts", "channel_podcasts", authorId)
+ end function,
+ playlists: function(authorId as string) as object
+ return CreateChannelFeed("Playlists", "channel_playlists", authorId)
+ end function,
+ channels: function(authorId as string) as object
+ return CreateChannelFeed("Channels", "channel_channels", authorId)
+ end function
+ }
+end function
+
+function CreateChannelFeed(title as string, endpoint as string, ucid as string) as object
+ return {
+ title: title,
+ apiType: "Invidious",
+ endpoint: endpoint,
+ pathParams: {
+ ucid: ucid
+ }
+ }
end function
diff --git a/playlet-lib/src/components/ChannelView/ChannelView.xml b/playlet-lib/src/components/ChannelView/ChannelView.xml
index f8b620d1..62c84169 100644
--- a/playlet-lib/src/components/ChannelView/ChannelView.xml
+++ b/playlet-lib/src/components/ChannelView/ChannelView.xml
@@ -11,44 +11,57 @@
color="0x242424">
-
+
+
-
+
-
-
+
-
+
+
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs
index 0a217571..5c965c6b 100644
--- a/playlet-lib/src/components/ContentNode/ChannelContentNode.bs
+++ b/playlet-lib/src/components/ContentNode/ChannelContentNode.bs
@@ -4,7 +4,6 @@ import "pkg:/source/utils/ErrorUtils.bs"
import "pkg:/components/Dialog/DialogUtils.bs"
function Init()
- m.top.latestVideos = m.top.findNode("latestVideos")
end function
function LoadChannel(invidiousNode as object) as void
diff --git a/playlet-lib/src/components/ContentNode/ChannelContentNode.xml b/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
index 876751f8..5a29053f 100644
--- a/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
+++ b/playlet-lib/src/components/ContentNode/ChannelContentNode.xml
@@ -14,15 +14,8 @@
-
-
+
-
-
-
-
-
-
\ No newline at end of file
diff --git a/playlet-lib/src/components/ContentNode/FeedContentNode.xml b/playlet-lib/src/components/ContentNode/FeedContentNode.xml
index e0c9eb70..fdd8dde5 100644
--- a/playlet-lib/src/components/ContentNode/FeedContentNode.xml
+++ b/playlet-lib/src/components/ContentNode/FeedContentNode.xml
@@ -2,7 +2,8 @@
-
+
+
\ No newline at end of file
diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs
index 6c67cb45..fd472fc1 100644
--- a/playlet-lib/src/components/Services/Invidious/InvidiousService.bs
+++ b/playlet-lib/src/components/Services/Invidious/InvidiousService.bs
@@ -4,6 +4,7 @@ import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/CryptoUtils.bs"
import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/Logging.bs"
+import "pkg:/components/VideoFeed/PaginationType.bs"
namespace Invidious
const INSTANCES_API = "https://api.invidious.io/instances.json?sort_by=type,users"
@@ -48,7 +49,9 @@ namespace Invidious
DefaultHandler: m.DefaultHandler,
AuthFeedHandler: m.AuthFeedHandler,
PlaylistHandler: m.PlaylistHandler,
- ChannelHandler: m.ChannelHandler
+ ChannelVideosHandler: m.ChannelVideosHandler,
+ ChannelPlaylistsHandler: m.ChannelPlaylistsHandler,
+ ChannelRelatedChannelsHandler: m.ChannelRelatedChannelsHandler
}
end function
@@ -155,18 +158,26 @@ namespace Invidious
requestData = contentNode.feed
endpoint = m.endpoints[requestData.endpoint]
- if endpoint = invalid or endpoint.pagination <> true
+ if endpoint = invalid or StringUtils.IsNullOrEmpty(endpoint.paginationType)
return
end if
- contentNode.pagination = true
- contentNode.page += 1
-
if not requestData.DoesExist("queryParams")
requestData.queryParams = {}
end if
- requestData.queryParams.page = contentNode.page
+ contentNode.paginationType = endpoint.paginationType
+
+ if endpoint.paginationType = PaginationType.Pages
+ contentNode.page += 1
+ requestData.queryParams.page = contentNode.page
+ else if endpoint.paginationType = PaginationType.Continuation
+ continuation = contentNode.continuation
+ if not StringUtils.IsNullOrEmpty(continuation)
+ requestData.queryParams.continuation = continuation
+ end if
+ end if
+
contentNode.feed = requestData
end function
@@ -254,21 +265,54 @@ namespace Invidious
end function
function DefaultHandler(m as object, requestData as object, response as object) as object
- return response.Json()
+ if response.StatusCode() = 200
+ json = response.Json()
+ return {
+ items: json
+ }
+ end if
+ return invalid
end function
function PlaylistHandler(m as object, requestData as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
- return json.videos
+ return {
+ items: json.videos
+ }
end if
return invalid
end function
- function ChannelHandler(m as object, requestData as object, response as object) as object
+ function ChannelVideosHandler(m as object, requestData as object, response as object) as object
if response.StatusCode() = 200
json = response.Json()
- return json.videos
+ return {
+ items: json.videos,
+ continuation: json.continuation
+ }
+ end if
+ return invalid
+ end function
+
+ function ChannelPlaylistsHandler(m as object, requestData as object, response as object) as object
+ if response.StatusCode() = 200
+ json = response.Json()
+ return {
+ items: json.playlists,
+ continuation: json.continuation
+ }
+ end if
+ return invalid
+ end function
+
+ function ChannelRelatedChannelsHandler(m as object, requestData as object, response as object) as object
+ if response.StatusCode() = 200
+ json = response.Json()
+ return {
+ items: json.relatedChannels,
+ continuation: json.continuation
+ }
end if
return invalid
end function
@@ -281,7 +325,9 @@ namespace Invidious
videos = []
videos.Append(json.notifications)
videos.Append(json.videos)
- return videos
+ return {
+ items: videos
+ }
end if
return invalid
end function
diff --git a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
index 011965a8..f2fee3eb 100644
--- a/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
+++ b/playlet-lib/src/components/Services/Invidious/InvidiousToContentNode.bs
@@ -115,22 +115,7 @@ namespace InvidiousContent
node.videoCountText = GetVideoCountText(item)
node.thumbnail = GetChannelThumbnail(item.authorThumbnails)
node.banner = GetChannelBanner(item.authorBanners)
-
- if item.latestVideos <> invalid
- newNodes = []
-
- for each video in item.latestVideos
- video.type = "video"
- videoNode = ToVideoContentNode(invalid, video, instance)
- if videoNode <> invalid
- newNodes.push(videoNode)
- end if
- end for
-
- if newNodes.Count() > 0
- node.latestVideos.appendChildren(newNodes)
- end if
- end if
+ SetIfExists(node, "tabs", item, "tabs")
return node
end function
@@ -245,7 +230,7 @@ namespace InvidiousContent
if authorBanners = invalid or authorBanners.Count() = 0
return ""
end if
- return authorBanners[authorBanners.Count() - 1].url
+ return authorBanners[0].url
end function
function GetVideoCountText(item as object) as string
diff --git a/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs b/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs
index 18b71f9a..a6776860 100644
--- a/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs
+++ b/playlet-lib/src/components/Services/SponsorBlock/SponsorBlockService.bs
@@ -107,9 +107,9 @@ namespace SponsorBlock
pixelEnd = (segment.segment[1] / videoDuration) * width
color = m.SegmentColor(segment.category)
' highlight's duration is zero, so it is not visble on the bar.
- ' Add a couple of pixels to see it
+ ' Add a few pixels to see it
if pixelStart = pixelEnd
- pixelEnd += 2
+ pixelEnd += 5
end if
bar.DrawRect(pixelStart, 0, pixelEnd - pixelStart, height, color)
end for
diff --git a/playlet-lib/src/components/VideoFeed/PaginationType.bs b/playlet-lib/src/components/VideoFeed/PaginationType.bs
new file mode 100644
index 00000000..34620f76
--- /dev/null
+++ b/playlet-lib/src/components/VideoFeed/PaginationType.bs
@@ -0,0 +1,4 @@
+enum PaginationType
+ Pages = "Pages"
+ Continuation = "Continuation"
+end enum
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
index 49166fe7..5f5d3c7b 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowCell/VideoRowCell.bs
@@ -1,5 +1,6 @@
import "pkg:/source/utils/TimeUtils.bs"
import "pkg:/source/utils/Types.bs"
+import "pkg:/source/utils/StringUtils.bs"
function Init()
m.titleLabel = m.top.FindNode("titleLabel")
@@ -23,36 +24,30 @@ function OnContentSet() as void
m.titleLabel.text = content.title
m.authorLabel.text = content.author
- if content.isUpcoming = true
- m.viewCountDateLabel.text = content.premiereTimestampText
- else
- publishedText = ValidString(content.publishedText)
- viewCountText = ValidString(content.viewCountText)
- if publishedText = "" and viewCountText = ""
- m.viewCountDateLabel.text = ""
- else
- m.viewCountDateLabel.text = `${publishedText} • ${viewCountText}`
+ if not StringUtils.IsNullOrEmpty(content.publishedText)
+ label = content.publishedText
+ if not StringUtils.IsNullOrEmpty(content.viewCountText)
+ label = `${label} • ${content.viewCountText}`
end if
+ m.viewCountDateLabel.text = label
+ else if content.isUpcoming = true
+ m.viewCountDateLabel.text = content.premiereTimestampText
end if
m.thumbnail.uri = content.thumbnail
- if content.isUpcoming = true
- m.upcomingRect.visible = true
- m.liveRect.visible = false
- m.durationRect.visible = false
- else if content.liveNow
- m.upcomingRect.visible = false
- m.liveRect.visible = true
- m.durationRect.visible = false
+ m.durationRect.visible = false
+ m.upcomingRect.visible = false
+ m.liveRect.visible = false
+
+ if ValidInt(content.lengthSeconds) <> 0
+ SetDurationText(content.lengthText)
+ m.durationRect.visible = true
else
- m.upcomingRect.visible = false
- m.liveRect.visible = false
- if ValidInt(content.lengthSeconds) <> 0
- SetDurationText(content.lengthText)
- m.durationRect.visible = true
- else
- m.durationRect.visible = false
+ if content.isUpcoming = true
+ m.upcomingRect.visible = true
+ else if content.liveNow
+ m.liveRect.visible = true
end if
end if
end function
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowList.bs b/playlet-lib/src/components/VideoFeed/VideoRowList.bs
index 6048fe4d..022bf4fe 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowList.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowList.bs
@@ -9,6 +9,8 @@ import "pkg:/components/VideoPlayer/VideoUtils.bs"
import "pkg:/components/PlaylistView/PlaylistUtils.bs"
import "pkg:/components/ChannelView/ChannelUtils.bs"
+' TODO:P1 add the option to remove a row if it does not have any content
+' E.g. NBC News does not return any related chnanels
function Init()
m.pendingLoadTasks = {}
end function
@@ -152,7 +154,7 @@ function GetRowsToLoad() as object
end if
subContentNodes = []
- range = m.top.numRows + 2
+ range = m.top.numRows + 1
for i = -range to range
index = focus + i
if index < 0
@@ -172,6 +174,8 @@ function GetRowsToLoad() as object
end function
function LoadRowContent(contentNode as object)
+ LogInfo("Loading row content:", contentNode.title)
+
contentNode.loadState = FeedLoadState.Loading
task = StartAsyncTask(VideoRowListRowContentTask, {
node: m.top,
diff --git a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
index fcac2db3..60883861 100644
--- a/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
+++ b/playlet-lib/src/components/VideoFeed/VideoRowListRowContentTask.bs
@@ -43,7 +43,7 @@ function VideoRowListRowContentTask(input as object) as object
instance = service.GetInstance()
itemNodes = []
- for each item in response.result
+ for each item in response.result.items
itemNode = InvidiousContent.ToRowCellContentNode(item, instance)
if itemNode <> invalid
itemNodes.Push(itemNode)
@@ -53,8 +53,20 @@ function VideoRowListRowContentTask(input as object) as object
RemovePlaceHolderItems(contentNode)
contentNode.appendChildren(itemNodes)
- if contentNode.pagination = true and response.result.Count() > 0
- contentNode.loadState = FeedLoadState.LoadedPage
+ hasContinuation = not StringUtils.IsNullOrEmpty(response.result.continuation)
+ if hasContinuation
+ contentNode.continuation = response.result.continuation
+ end if
+
+ if response.result.items.Count() > 0
+ pageType = contentNode.paginationType
+ if pageType = PaginationType.Continuation and hasContinuation
+ contentNode.loadState = FeedLoadState.LoadedPage
+ else if pageType = PaginationType.Pages
+ contentNode.loadState = FeedLoadState.LoadedPage
+ else
+ contentNode.loadState = FeedLoadState.Loaded
+ end if
else
contentNode.loadState = FeedLoadState.Loaded
end if
diff --git a/playlet-lib/src/config/invidious_video_api.json5 b/playlet-lib/src/config/invidious_video_api.json5
index 573e5c55..eb5d9ddc 100644
--- a/playlet-lib/src/config/invidious_video_api.json5
+++ b/playlet-lib/src/config/invidious_video_api.json5
@@ -62,7 +62,7 @@
name: "search",
displayName: "Search",
url: "/api/v1/search",
- pagination: true,
+ paginationType: "Pages",
queryParams: {
q: {
required: true,
@@ -122,7 +122,7 @@
default: 20,
},
},
- pagination: true,
+ paginationType: "Pages",
},
{
name: "playlists",
@@ -135,13 +135,14 @@
displayName: "Playlist",
url: "/api/v1/playlists/{plid}",
responseHandler: "PlaylistHandler",
- pagination: true,
+ paginationType: "Pages",
},
{
- name: "channel",
- displayName: "Channel",
- url: "/api/v1/channels/videos/{ucid}",
- responseHandler: "ChannelHandler",
+ name: "channel_videos",
+ displayName: "Channel videos",
+ url: "/api/v1/channels/{ucid}/videos",
+ responseHandler: "ChannelVideosHandler",
+ paginationType: "Continuation",
queryParams: {
sort_by: {
required: false,
@@ -149,5 +150,46 @@
},
},
},
+ {
+ name: "channel_playlists",
+ displayName: "Channel playlists",
+ url: "/api/v1/channels/{ucid}/playlists",
+ responseHandler: "ChannelPlaylistsHandler",
+ paginationType: "Continuation",
+ queryParams: {
+ sort_by: {
+ required: false,
+ type: ["newest", "oldest", "last"],
+ },
+ },
+ },
+ {
+ name: "channel_shorts",
+ displayName: "Channel shorts",
+ url: "/api/v1/channels/{ucid}/shorts",
+ responseHandler: "ChannelVideosHandler",
+ paginationType: "Continuation",
+ },
+ {
+ name: "channel_streams",
+ displayName: "Channel livestreams",
+ url: "/api/v1/channels/{ucid}/streams",
+ responseHandler: "ChannelVideosHandler",
+ paginationType: "Continuation",
+ },
+ {
+ name: "channel_podcasts",
+ displayName: "Channel podcasts",
+ url: "/api/v1/channels/{ucid}/podcasts",
+ responseHandler: "ChannelPlaylistsHandler",
+ paginationType: "Continuation",
+ },
+ {
+ name: "channel_channels",
+ displayName: "Related channels",
+ url: "/api/v1/channels/{ucid}/channels",
+ responseHandler: "ChannelRelatedChannelsHandler",
+ paginationType: "Continuation",
+ },
],
}
diff --git a/playlet-lib/src/source/services/HttpClient.bs b/playlet-lib/src/source/services/HttpClient.bs
index 6bb6391f..d9ca93c5 100644
--- a/playlet-lib/src/source/services/HttpClient.bs
+++ b/playlet-lib/src/source/services/HttpClient.bs
@@ -532,7 +532,7 @@ namespace HttpClient
else if m.IsCancelled()
m._errorMessage = "Request cancelled."
else if type(m.event) = "roUrlEvent"
- m._errorMessage = `Reason :${m.event.GetFailureReason() }\nStatusCode: ${m.StatusCode()}\nBody: ${m.event.GetString()}`
+ m._errorMessage = `Reason :${m.event.GetFailureReason() }\nStatusCode: ${m.StatusCode()}\nRequestId: ${m.event.GetSourceIdentity()}\nBody: ${m.event.GetString()}`
end if
end if
diff --git a/playlet-web/src/lib/Api/InvidiousApi.ts b/playlet-web/src/lib/Api/InvidiousApi.ts
index ccdada36..e4695207 100644
--- a/playlet-web/src/lib/Api/InvidiousApi.ts
+++ b/playlet-web/src/lib/Api/InvidiousApi.ts
@@ -12,7 +12,6 @@ export class InvidiousApi {
// Note: handlers for authenticated requests are not needed, since they are handled server side
this.responseHandlers = {
"DefaultHandler": (requestData, response) => this.DefaultHandler(requestData, response),
- "PlaylistHandler": (requestData, response) => this.PlaylistHandler(requestData, response),
}
}
@@ -91,12 +90,8 @@ export class InvidiousApi {
}
private async DefaultHandler(requestData, response) {
- return await response.json();
- }
-
- private async PlaylistHandler(requestData, response) {
- const playlist = await response.json();
- return playlist.videos
+ const items = await response.json();
+ return { items };
}
private makeUrl(url: string, params: any) {
diff --git a/playlet-web/src/lib/Screens/Home/ChannelCell.svelte b/playlet-web/src/lib/Screens/Home/ChannelCell.svelte
new file mode 100644
index 00000000..1345fb5c
--- /dev/null
+++ b/playlet-web/src/lib/Screens/Home/ChannelCell.svelte
@@ -0,0 +1,82 @@
+
+
+
+
+
diff --git a/playlet-web/src/lib/Screens/Home/ScreenHomeRow.svelte b/playlet-web/src/lib/Screens/Home/ScreenHomeRow.svelte
index 41182066..50f94f35 100644
--- a/playlet-web/src/lib/Screens/Home/ScreenHomeRow.svelte
+++ b/playlet-web/src/lib/Screens/Home/ScreenHomeRow.svelte
@@ -3,20 +3,24 @@
import { invidiousVideoApiStore, playletStateStore } from "lib/Stores";
import VideoCell from "lib/Screens/Home/VideoCell.svelte";
import PlaylistCell from "lib/Screens/Home/PlaylistCell.svelte";
+ import ChannelCell from "./ChannelCell.svelte";
export let requestData: any = undefined;
export let videos = undefined;
+ let itemWidths = [];
+
let carouselElement;
let scrollStart = 0;
let scrollEnd = 0;
- // w-80 p-2: 320px + 16px padding on each side
- const itemWidth = 320 + 16 * 2;
+ // w-80|w-60 p-2: 320px|240px + 16px padding on each side
+ const videoItemWidth = 320 + 16 * 2;
+ const channelItemWidth = 240 + 16 * 2;
$: {
- if (carouselElement && videos && videos.length) {
+ if (carouselElement && itemWidths && itemWidths.length) {
recalculateVisibileCells();
}
}
@@ -37,26 +41,49 @@
async function updateRow() {
const result = await invidiousApi.makeRequest(requestData);
- if (result) {
- result.forEach((item) => {
+ if (result && result.items) {
+ result.items.forEach((item) => {
if (item.videoId) {
item.type = "video";
} else if (item.playlistId) {
item.type = "playlist";
}
});
- videos = result.filter(
- (video) => video.type === "video" || video.type === "playlist"
- );
+ videos = result.items;
+ itemWidths = videos.map((video) => {
+ if (video.type === "channel") {
+ return channelItemWidth;
+ } else {
+ return videoItemWidth;
+ }
+ });
}
}
function recalculateVisibileCells() {
- const scrollLeft = carouselElement.scrollLeft;
+ let scrollLeft = carouselElement.scrollLeft;
const clientWidth = carouselElement.clientWidth || window.innerWidth;
- scrollStart = Math.floor(scrollLeft / itemWidth) - 1;
- scrollEnd = Math.ceil((scrollLeft + clientWidth) / itemWidth) + 1;
+ scrollStart = 0;
+ while (
+ scrollStart < itemWidths.length &&
+ scrollLeft > itemWidths[scrollStart]
+ ) {
+ scrollLeft -= itemWidths[scrollStart];
+ scrollStart++;
+ }
+
+ scrollEnd = scrollStart;
+ while (
+ scrollEnd < itemWidths.length &&
+ scrollLeft + clientWidth > itemWidths[scrollEnd]
+ ) {
+ scrollLeft -= itemWidths[scrollEnd];
+ scrollEnd++;
+ }
+
+ scrollStart = Math.max(0, scrollStart - 1);
+ scrollEnd = Math.min(itemWidths.length - 1, scrollEnd + 1);
}
@@ -70,12 +97,16 @@
on:scroll={recalculateVisibileCells}
>
{#each videos as video, i}
-
+
{#if i >= scrollStart && i <= scrollEnd}
{#if video.type === "video"}
{:else if video.type === "playlist"}
+ {:else if video.type === "channel"}
+
{/if}
{/if}
diff --git a/playlet-web/src/lib/Screens/SearchScreen.svelte b/playlet-web/src/lib/Screens/SearchScreen.svelte
index 6afc113c..3aebc86e 100644
--- a/playlet-web/src/lib/Screens/SearchScreen.svelte
+++ b/playlet-web/src/lib/Screens/SearchScreen.svelte
@@ -5,6 +5,7 @@
import VideoCell from "lib/Screens/Home/VideoCell.svelte";
import PlaylistCell from "lib/Screens/Home/PlaylistCell.svelte";
import SearchThinIcon from "assets/search-thin-icon.svg.svelte";
+ import ChannelCell from "./Home/ChannelCell.svelte";
export let visibility: boolean;
@@ -156,6 +157,8 @@
{:else if video.type === "playlist"}
+ {:else if video.type === "channel"}
+
{/if}
{/each}
diff --git a/playlet-web/tsconfig.json b/playlet-web/tsconfig.json
index 8fdba151..e59560f9 100644
--- a/playlet-web/tsconfig.json
+++ b/playlet-web/tsconfig.json
@@ -22,7 +22,8 @@
*/
"allowJs": true,
"checkJs": true,
- "isolatedModules": true
+ "isolatedModules": true,
+ "strict": false
},
"include": [
"src/**/*.d.ts",