Minor fixes

This commit is contained in:
WardPearce
2024-03-23 13:30:14 +13:00
parent 2346017c36
commit 3c91eed236
3 changed files with 22 additions and 9 deletions
+6 -2
View File
@@ -71,8 +71,12 @@ export async function getSubscriptions(): Promise<Subscription[]> {
}
export async function amSubscribed(authorId: string): Promise<boolean> {
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) {
+8 -6
View File
@@ -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 {}
}
</script>
@@ -56,7 +58,7 @@
{#if replies}
{#each replies.comments as reply}
<svelte:self comment={reply} />
<svelte:self comment={reply} {videoId} />
{/each}
{/if}
@@ -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)
};