diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index bc965fa6..ea9c5dc1 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -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( diff --git a/materialious/src/lib/components/thumbnail/VideoThumbnail.svelte b/materialious/src/lib/components/thumbnail/VideoThumbnail.svelte index 0eb24234..c008935c 100644 --- a/materialious/src/lib/components/thumbnail/VideoThumbnail.svelte +++ b/materialious/src/lib/components/thumbnail/VideoThumbnail.svelte @@ -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 @@
300 : false}> Thumbnail for video
- {#if beenWatched} + {#if progress !== undefined}
check