From 930aa24d4aa2c246c1cf53a921bae6aca5d74e79 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Wed, 4 Mar 2026 23:21:40 +1300 Subject: [PATCH] Ablity to disable watch history --- materialious/src/lib/api/backend/history.ts | 4 ---- materialious/src/lib/api/index.ts | 15 ++++++++++++- .../src/lib/components/player/Player.svelte | 10 --------- .../lib/components/settings/Interface.svelte | 20 ++++++++++++++++- .../settings/InternalAccount.svelte | 22 ------------------- 5 files changed, 33 insertions(+), 38 deletions(-) diff --git a/materialious/src/lib/api/backend/history.ts b/materialious/src/lib/api/backend/history.ts index 103dec9d..951aeb17 100644 --- a/materialious/src/lib/api/backend/history.ts +++ b/materialious/src/lib/api/backend/history.ts @@ -2,8 +2,6 @@ import sodium from 'libsodium-wrappers-sumo'; import { decryptWithMasterKey, encryptWithMasterKey, getRawKey, getSecureHash } from './encryption'; import type { VideoPlay, VideoWatchHistory } from '../model'; import { getBestThumbnail } from '$lib/images'; -import { get } from 'svelte/store'; -import { watchHistoryEnabledStore } from '$lib/store'; export async function updateWatchHistoryBackend(videoId: string, progress: number) { await sodium.ready; @@ -121,8 +119,6 @@ export async function deleteWatchHistoryBackend() { } export async function saveWatchHistoryBackend(video: VideoPlay, progress: number = 0) { - if (!get(watchHistoryEnabledStore)) return; - await sodium.ready; const rawKey = await getRawKey(); if (!rawKey) return; diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index 082efe87..bc965fa6 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -1,6 +1,11 @@ import { getVideoYTjs } from '$lib/api/youtubejs/video'; import { get } from 'svelte/store'; -import { invidiousAuthStore, playerYouTubeJsAlways, rawMasterKeyStore } from '../store'; +import { + invidiousAuthStore, + playerYouTubeJsAlways, + rawMasterKeyStore, + watchHistoryEnabledStore +} from '../store'; import type { ChannelPage, Comments, @@ -287,6 +292,8 @@ export async function getWatchHistory( fetchOptions: undefined } ): Promise { + if (!get(watchHistoryEnabledStore)) return []; + if (isOwnBackend()?.internalAuth && get(rawMasterKeyStore)) { return getWatchHistoryBackend(options); } @@ -319,6 +326,8 @@ export async function getWatchHistory( export async function getVideoWatchHistory( videoId: string ): Promise { + if (!get(watchHistoryEnabledStore)) return; + if (isOwnBackend()?.internalAuth && get(rawMasterKeyStore)) { return getVideoWatchHistoryBackend(videoId); } @@ -339,6 +348,8 @@ export async function updateWatchHistory( progress: number, fetchOptions: RequestInit = {} ) { + if (!get(watchHistoryEnabledStore)) return; + if (isOwnBackend()?.internalAuth && get(rawMasterKeyStore)) { return updateWatchHistoryBackend(videoId, progress); } @@ -349,6 +360,8 @@ export async function updateWatchHistory( } export async function saveWatchHistory(video: VideoPlay, progress: number = 0) { + if (!get(watchHistoryEnabledStore)) return; + if (isOwnBackend()?.internalAuth && get(rawMasterKeyStore)) { return saveWatchHistoryBackend(video, progress); } diff --git a/materialious/src/lib/components/player/Player.svelte b/materialious/src/lib/components/player/Player.svelte index 9d4cb723..8bbe552f 100644 --- a/materialious/src/lib/components/player/Player.svelte +++ b/materialious/src/lib/components/player/Player.svelte @@ -29,7 +29,6 @@ playerState, playerTheatreModeIsActive, playerYouTubeJsFallback, - rawMasterKeyStore, sponsorBlockCategoriesStore, sponsorBlockDisplayToastStore, sponsorBlockStore, @@ -728,15 +727,6 @@ let toSetTime = 0; - try { - const playerPos = localStorage.getItem(`v_${data.video.videoId}`); - if (playerPos && Number(playerPos) > toSetTime) { - toSetTime = Number(playerPos); - } - } catch { - // Continue regardless of error - } - const watchHistory = await getVideoWatchHistory(data.video.videoId); if (watchHistory && watchHistory.progress > toSetTime) toSetTime = watchHistory.progress; diff --git a/materialious/src/lib/components/settings/Interface.svelte b/materialious/src/lib/components/settings/Interface.svelte index 7d1b28e4..d9601551 100644 --- a/materialious/src/lib/components/settings/Interface.svelte +++ b/materialious/src/lib/components/settings/Interface.svelte @@ -31,7 +31,8 @@ interfaceSearchHistoryEnabled, interfaceSearchSuggestionsStore, searchHistoryStore, - themeColorStore + themeColorStore, + watchHistoryEnabledStore } from '../../store'; import { addToast } from '../Toast.svelte'; import { tick } from 'svelte'; @@ -274,6 +275,23 @@ +
+ +
+