diff --git a/materialious/src/lib/Search.svelte b/materialious/src/lib/Search.svelte index ecbad408..35e341cf 100644 --- a/materialious/src/lib/Search.svelte +++ b/materialious/src/lib/Search.svelte @@ -87,7 +87,7 @@ search (showSearchBox = true)} /> diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index 4c63b607..457114df 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -2,9 +2,8 @@ import { createEventDispatcher, onDestroy, onMount } from 'svelte'; import { _ } from 'svelte-i18n'; import { get } from 'svelte/store'; - import { getDeArrow, getThumbnail, getVideo, getVideoProgress } from './Api'; + import { getChannel, getDeArrow, getThumbnail, getVideo, getVideoProgress } from './Api'; import type { Notification, PlaylistPageVideo, Video, VideoBase, VideoPlay } from './Api/model'; - import ShareVideo from './ShareVideo.svelte'; import { cleanNumber, getBestThumbnail, letterCase, proxyVideoUrl, videoLength } from './misc'; import type { PlayerEvents } from './player'; import { @@ -32,6 +31,8 @@ let videoPreviewVolume: number = 0.4; let imgHeight: number; + let authorImg: string = ''; + let proxyVideos = get(playerProxyVideosStore); let watchUrl = new URL(`${location.origin}/watch/${video.videoId}`); @@ -70,6 +71,17 @@ else sideways = true; } + async function loadAuthor() { + const channel = await getChannel(video.authorId); + + const authorImgObject = new Image(); + authorImgObject.src = getBestThumbnail(channel.authorThumbnails); + + authorImgObject.onload = () => { + authorImg = authorImgObject.src; + }; + } + onMount(async () => { try { thumbnailHidden = localStorage.getItem(`v_h_${video.videoId}`) === '1'; @@ -80,6 +92,9 @@ return; } + // Load author details in background. + loadAuthor(); + // Check if sideways should be enabled or disabled. disableSideways(); @@ -218,14 +233,6 @@ imgHeight = document.getElementById('thumbnail-container')?.clientHeight as number; } - - function hideVideo() { - try { - localStorage.setItem(`v_h_${video.videoId}`, '1'); - dispatch('videoHidden'); - thumbnailHidden = true; - } catch {} - } {#if !thumbnailHidden} @@ -244,7 +251,9 @@ on:click={syncChangeVideo} > {#if loading} - + {#if !sideways} +
+ {/if} {:else if loaded} {#if showVideoPreview && videoPreview}
@@ -312,34 +321,35 @@ {/if}
-
+
- {letterCase(video.title.trimEnd())} + {letterCase(video.title.trimEnd())}
- {video.author} - - {#if !('publishedText' in video) && 'viewCountText' in video} -  • {video.viewCountText}{/if} - - + {video.author} +