Ablity to disable watch history
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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<VideoWatchHistory[]> {
|
||||
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<VideoWatchHistory | undefined> {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="field no-margin">
|
||||
<nav class="no-padding">
|
||||
<div class="max">
|
||||
<div>{$_('layout.historyEnabled')}</div>
|
||||
</div>
|
||||
<label class="switch" tabindex="0">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={$watchHistoryEnabledStore}
|
||||
onclick={() => watchHistoryEnabledStore.set(!$watchHistoryEnabledStore)}
|
||||
role="switch"
|
||||
/>
|
||||
<span></span>
|
||||
</label>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="field no-margin">
|
||||
<nav class="no-padding">
|
||||
<div class="max">
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { _ } from '$lib/i18n';
|
||||
import { materialiousLogout } from '$lib/auth';
|
||||
import { watchHistoryEnabledStore } from '$lib/store';
|
||||
|
||||
let clickCount = $state(0);
|
||||
const clicksToDelte = 3;
|
||||
@@ -22,27 +21,6 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="field no-margin">
|
||||
<nav class="no-padding">
|
||||
<div class="max">
|
||||
<div>{$_('layout.historyEnabled')}</div>
|
||||
</div>
|
||||
<label class="switch" tabindex="0">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={$watchHistoryEnabledStore}
|
||||
onclick={() => watchHistoryEnabledStore.set(!$watchHistoryEnabledStore)}
|
||||
role="switch"
|
||||
/>
|
||||
<span></span>
|
||||
</label>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="space"></div>
|
||||
<div class="divider"></div>
|
||||
<div class="space"></div>
|
||||
|
||||
<button class="tertiary" onclick={deleteAccount}>
|
||||
<i>warning</i>
|
||||
<span>{$_('layout.deleteAccount')}</span>
|
||||
|
||||
Reference in New Issue
Block a user