From 0d3011dacd1b31d5ff24875d22af1404c5f9f90b Mon Sep 17 00:00:00 2001 From: WardPearce Date: Wed, 5 Nov 2025 00:26:34 +1300 Subject: [PATCH] Improved search filtering --- materialious/src/lib/api/index.ts | 17 +- .../src/lib/components/ItemsList.svelte | 4 +- .../src/lib/components/Thumbnail.svelte | 2 - materialious/src/lib/i18n/locales/en.json | 8 + .../routes/(app)/search/[slug]/+page.svelte | 162 ++++++++++++------ 5 files changed, 135 insertions(+), 58 deletions(-) diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index c3e40d9d..6a3e1705 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -179,13 +179,18 @@ export async function getHashtag(tag: string, page: number = 0): Promise<{ resul return await resp.json(); } +export interface SearchOptions { + sort_by?: 'relevance' | 'rating' | 'upload_date' | 'view_count'; + type?: 'video' | 'playlist' | 'channel' | 'all'; + duration?: 'short' | 'medium' | 'long'; + date?: 'hour' | 'today' | 'week' | 'month' | 'year'; + features?: string; + page?: string; +} + export async function getSearch( search: string, - options: { - sort_by?: 'relevance' | 'rating' | 'upload_date' | 'view_count'; - type?: 'video' | 'playlist' | 'channel' | 'all'; - page?: string; - }, + options: SearchOptions, fetchOptions?: RequestInit ): Promise<(Channel | Video | Playlist | HashTag)[]> { if (typeof options.sort_by === 'undefined') { @@ -193,7 +198,7 @@ export async function getSearch( } if (typeof options.type === 'undefined') { - options.type = 'video'; + options.type = 'all'; } if (typeof options.page === 'undefined') { diff --git a/materialious/src/lib/components/ItemsList.svelte b/materialious/src/lib/components/ItemsList.svelte index 5b2000f9..fa23bca5 100644 --- a/materialious/src/lib/components/ItemsList.svelte +++ b/materialious/src/lib/components/ItemsList.svelte @@ -263,7 +263,9 @@ }} > {#if item.type === 'video' || item.type === 'shortVideo' || item.type === 'stream'} - + {#key item.videoId} + + {/key} {#if $authStore && decodeURIComponent($authStore.username) === playlistAuthor && 'indexId' in item}
+ + +
+
+ {#each filters as filter} +
+
{filter.title}
+
    + {#each filter.options as filterOption} +
  • + +
  • + {/each} +
+
+ {/each} +
+
+ + +
{#if $searchCacheStore[data.searchStoreId]}