diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index 5feba859..4535254e 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -68,6 +68,20 @@ export function setRegion(url: URL): URL { return url; } +export class HTTPError { + msg: string; + response: Response; + + constructor(msg: string, response: Response) { + this.msg = msg; + this.response = response; + } + + toString() { + return this.msg; + } +} + export async function fetchErrorHandle(response: Response): Promise { if (!response.ok) { let message = 'Internal error'; @@ -80,8 +94,9 @@ export async function fetchErrorHandle(response: Response): Promise { // Continue regardless of error } - throw Error( - `${response.status} - ${response.statusText}\n${decodeURIComponent(response.url)}\n${message}` + throw new HTTPError( + `${response.status} - ${response.statusText}\n${decodeURIComponent(response.url)}\n${message}`, + response ); } diff --git a/materialious/src/lib/components/Logo.svelte b/materialious/src/lib/components/Logo.svelte index b3c9edd7..f57dae69 100644 --- a/materialious/src/lib/components/Logo.svelte +++ b/materialious/src/lib/components/Logo.svelte @@ -6,9 +6,10 @@ interface Props { classes?: string; + size?: string; } - let { classes = '' }: Props = $props(); + let { classes = '', size = '70px' }: Props = $props(); let fillColor = $state(''); @@ -35,8 +36,8 @@ { + setActiveVideoTrack(); + setActiveAudioTrack(); + }); }); function setActiveVideoTrack() { diff --git a/materialious/src/lib/store.ts b/materialious/src/lib/store.ts index 4b168c42..dd1fbdac 100644 --- a/materialious/src/lib/store.ts +++ b/materialious/src/lib/store.ts @@ -375,3 +375,5 @@ export const channelCacheStore: Writable<{ displayContent: { [key: string]: ChannelContent }; }; }> = writable({}); + +export const hideSearchStore: Writable = writable(false); diff --git a/materialious/src/routes/(app)/+layout.svelte b/materialious/src/routes/(app)/+layout.svelte index 62007890..54625b7a 100644 --- a/materialious/src/routes/(app)/+layout.svelte +++ b/materialious/src/routes/(app)/+layout.svelte @@ -24,7 +24,8 @@ rawMasterKeyStore, syncPartyPeerStore, themeColorStore, - backendInUseStore + backendInUseStore, + hideSearchStore } from '$lib/store'; import { Capacitor } from '@capacitor/core'; import 'beercss'; @@ -237,10 +238,11 @@
-
- -
- + {#if !$hideSearchStore} +
+ +
+ {/if} {#if !mobileSearchShow}
{/if} diff --git a/materialious/src/routes/(app)/+page.svelte b/materialious/src/routes/(app)/+page.svelte index 59e6a030..e0d5262d 100644 --- a/materialious/src/routes/(app)/+page.svelte +++ b/materialious/src/routes/(app)/+page.svelte @@ -1,23 +1,40 @@ {#if data.popularDisabled} -
+
- -

{$_('disabled')}

-

{$_('popularPageDisabled')}

+ +

Materialious

+
{:else} {/if} + + diff --git a/materialious/src/routes/(app)/+page.ts b/materialious/src/routes/(app)/+page.ts index 12aaec35..8ae46ee6 100644 --- a/materialious/src/routes/(app)/+page.ts +++ b/materialious/src/routes/(app)/+page.ts @@ -1,6 +1,6 @@ import { goto } from '$app/navigation'; import { resolve } from '$app/paths'; -import { getPopular } from '$lib/api/index'; +import { getPopular, HTTPError } from '$lib/api/index'; import { isYTBackend } from '$lib/misc'; import { feedCacheStore, invidiousInstanceStore } from '$lib/store'; import { error } from '@sveltejs/kit'; @@ -22,18 +22,18 @@ export async function load() { let popularDisabled: boolean = false; if (!popular) { - let errorMsg: Error | undefined; + let errorObj: HTTPError | undefined; try { popular = await getPopular(); } catch (popularError) { - errorMsg = popularError as Error; + if (popularError instanceof HTTPError) errorObj = popularError; } - if (errorMsg) { - if (errorMsg.toString() === 'Error: Administrator has disabled this endpoint.') { + if (errorObj) { + if (errorObj.response.status === 403) { popularDisabled = true; } else { - throw error(500, errorMsg); + throw error(500, errorObj.toString()); } } diff --git a/materialious/src/routes/+layout.ts b/materialious/src/routes/+layout.ts index 2558df89..b2545454 100644 --- a/materialious/src/routes/+layout.ts +++ b/materialious/src/routes/+layout.ts @@ -12,7 +12,8 @@ import { invidiousInstanceStore, interfaceDefaultPage, isAndroidTvStore, - rawMasterKeyStore + rawMasterKeyStore, + hideSearchStore } from '$lib/store'; import { get, type Writable } from 'svelte/store'; import { Capacitor } from '@capacitor/core';