Fixed getting thumbnail progress

This commit is contained in:
WardPearce
2026-03-05 13:43:06 +13:00
parent a24e7971cf
commit 05889f09a6
2 changed files with 10 additions and 30 deletions
+6 -3
View File
@@ -302,7 +302,7 @@ export async function getWatchHistory(
watchHistory.sort((a, b) => b.watched.getTime() - a.watched.getTime());
if (options.videoIds) {
watchHistory = watchHistory.filter((item) => !options.videoIds?.includes(item.videoId));
watchHistory = watchHistory.filter((item) => options.videoIds?.includes(item.videoId));
}
const cullAfter = 1000;
@@ -317,10 +317,13 @@ export async function getWatchHistory(
const maxResults = 100;
const start = (options.page ?? 1 - 1) * maxResults;
const page = options.page ?? 1; // default to page 1
const start = (page - 1) * maxResults;
const end = start + maxResults;
return watchHistory.splice(start, end);
watchHistory = watchHistory.slice(start, end);
return watchHistory;
}
export async function getVideoWatchHistory(
@@ -18,13 +18,11 @@
deArrowEnabledStore,
isAndroidTvStore,
playerSavePlaybackPositionStore,
playerState,
rawMasterKeyStore
playerState
} from '$lib/store';
import { relativeTimestamp } from '$lib/time';
import { queueGetWatchHistory } from '$lib/api/historyPool';
import { page } from '$app/state';
import { isOwnBackend } from '$lib/shared';
import { getDeArrow, getThumbnailDeArrow } from '$lib/api/dearrow';
interface Props {
@@ -44,18 +42,7 @@
watchUrl.searchParams.set('playlist', playlistId);
}
let beenWatched: boolean = $state(false);
let progress: string | undefined = $state();
if (get(playerSavePlaybackPositionStore)) {
try {
progress = localStorage.getItem(`v_${video.videoId}`) ?? undefined;
} catch {
progress = undefined;
}
} else {
progress = undefined;
}
let thumbnailSrc = $state(
'thumbnail' in video ? video.thumbnail : (getBestThumbnail(video.videoThumbnails) as string)
@@ -99,24 +86,14 @@
} else sideways = true;
}
function checkIfWatched() {
beenWatched = !!(progress && !page.url.pathname.endsWith('/history'));
}
onMount(async () => {
// Check if sideways should be enabled or disabled.
disableSideways();
checkIfWatched();
if (
!page.url.pathname.endsWith('/history') &&
isOwnBackend()?.internalAuth &&
get(rawMasterKeyStore)
)
if (!page.url.pathname.endsWith('/history'))
queueGetWatchHistory(video.videoId).then((watchHistory) => {
if (watchHistory) {
progress = watchHistory.progress.toString();
checkIfWatched();
}
});
});
@@ -144,7 +121,7 @@
<div class:crop={thumbnailHTMLElement ? thumbnailHTMLElement.height > 300 : false}>
<img
class="responsive"
class:watched={beenWatched}
class:watched={progress !== undefined}
{...thumbnail.image}
bind:this={thumbnailHTMLElement}
alt="Thumbnail for video"
@@ -156,7 +133,7 @@
style="height: 200px;"
></div>
{#if beenWatched}
{#if progress !== undefined}
<div class="chip surface-container-highest">
<i>check</i>
</div>