From 3c91eed2360c24fa8e3cd1f5903408c886da0d41 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Sat, 23 Mar 2024 13:30:14 +1300 Subject: [PATCH] Minor fixes --- materialious/src/lib/Api/index.ts | 8 ++++++-- materialious/src/lib/Comment.svelte | 14 ++++++++------ materialious/src/routes/watch/[slug]/+page.ts | 9 ++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/materialious/src/lib/Api/index.ts b/materialious/src/lib/Api/index.ts index d05ec226..68a2d11b 100644 --- a/materialious/src/lib/Api/index.ts +++ b/materialious/src/lib/Api/index.ts @@ -71,8 +71,12 @@ export async function getSubscriptions(): Promise { } export async function amSubscribed(authorId: string): Promise { - const subscriptions = (await getSubscriptions()).filter(sub => sub.authorId === authorId); - return subscriptions.length === 1; + try { + const subscriptions = (await getSubscriptions()).filter(sub => sub.authorId === authorId); + return subscriptions.length === 1; + } catch { + return false; + } } export async function postSubscribe(authorId: string) { diff --git a/materialious/src/lib/Comment.svelte b/materialious/src/lib/Comment.svelte index 778cb09c..72cd0f06 100644 --- a/materialious/src/lib/Comment.svelte +++ b/materialious/src/lib/Comment.svelte @@ -9,11 +9,13 @@ let replies: Comments; async function loadReplies(continuation: string) { - replies = await getComments(videoId, { - continuation: continuation, - sort_by: 'top', - source: 'youtube' - }); + try { + replies = await getComments(videoId, { + continuation: continuation, + sort_by: 'top', + source: 'youtube' + }); + } catch {} } @@ -56,7 +58,7 @@ {#if replies} {#each replies.comments as reply} - + {/each} {/if} diff --git a/materialious/src/routes/watch/[slug]/+page.ts b/materialious/src/routes/watch/[slug]/+page.ts index 7c9f2ebc..b486c142 100644 --- a/materialious/src/routes/watch/[slug]/+page.ts +++ b/materialious/src/routes/watch/[slug]/+page.ts @@ -9,10 +9,17 @@ export async function load({ params }) { postHistory(video.videoId); } + let comments; + try { + comments = video.liveNow ? null : await getComments(params.slug, { sort_by: "top", source: "youtube" }); + } catch { + comments = null; + } + return { video: video, returnYTDislikes: get(returnYtDislikes) ? await getDislikes(params.slug) : null, - comments: video.liveNow ? null : await getComments(params.slug, { sort_by: "top", source: "youtube" }), + comments: comments, subscribed: await amSubscribed(video.authorId), content: phaseDescription(video.description) };