diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index a4288366..b1971860 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -170,6 +170,17 @@ export async function getChannelContent( return await resp.json(); } +export async function searchChannelContent( + channelId: string, + search: string, + fetchOptions?: RequestInit +) { + const path = buildPath(`channel/${channelId}/search`); + path.search = new URLSearchParams({ q: search }).toString(); + const resp = await fetchErrorHandle(await fetch(path, fetchOptions)); + return await resp.json(); +} + export async function getSearchSuggestions( search: string, fetchOptions?: RequestInit diff --git a/materialious/src/routes/(app)/channel/[slug]/+page.svelte b/materialious/src/routes/(app)/channel/[slug]/+page.svelte index 3100978c..33fc6592 100644 --- a/materialious/src/routes/(app)/channel/[slug]/+page.svelte +++ b/materialious/src/routes/(app)/channel/[slug]/+page.svelte @@ -4,6 +4,7 @@ deleteUnsubscribe, getChannelContent, postSubscribe, + searchChannelContent, type channelContentTypes, type channelSortBy } from '$lib/api'; @@ -29,9 +30,16 @@ let sortBy: channelSortBy = $state('newest'); const sortByOptions: channelSortBy[] = ['newest', 'oldest', 'popular']; + let showSearch: boolean = $state(false); + let channelSearch: string = $state(''); + let displayContent: ChannelContentPlaylists | ChannelContentVideos | undefined = $state(undefined); + async function searchChannel() { + displayContent = await searchChannelContent(data.channel.authorId, channelSearch); + } + async function loadMore(event: InfiniteEvent) { if (typeof displayContent === 'undefined') return; @@ -213,22 +221,43 @@ - + displayContent = await getChannelContent(data.channel.authorId, { + type: tab, + sortBy: sortBy + }); + }} + class:active={sortBy === sortingOption}>{$_(sortingOption)} + {/each} + + +
+ {#if showSearch} +
+ search +
+ {:else} + + + {/if} +
+
diff --git a/materialious/src/routes/(app)/subscriptions/manage/+page.svelte b/materialious/src/routes/(app)/subscriptions/manage/+page.svelte index 28107bbf..4396e975 100644 --- a/materialious/src/routes/(app)/subscriptions/manage/+page.svelte +++ b/materialious/src/routes/(app)/subscriptions/manage/+page.svelte @@ -33,7 +33,7 @@
-
+
search