Added option to save watch history
This commit is contained in:
@@ -2,6 +2,8 @@ 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 updateWatchHistory(videoId: string, progress: number) {
|
||||
await sodium.ready;
|
||||
@@ -115,6 +117,8 @@ export async function deleteWatchHistory() {
|
||||
}
|
||||
|
||||
export async function saveWatchHistory(video: VideoPlay, progress: number = 0) {
|
||||
if (!get(watchHistoryEnabledStore)) return;
|
||||
|
||||
await sodium.ready;
|
||||
const rawKey = await getRawKey();
|
||||
if (!rawKey) return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { _ } from '$lib/i18n';
|
||||
import { materialiousLogout } from '$lib/misc';
|
||||
import { watchHistoryEnabledStore } from '$lib/store';
|
||||
|
||||
let clickCount = $state(0);
|
||||
const clicksToDelte = 3;
|
||||
@@ -21,8 +22,27 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<h6>Delete account</h6>
|
||||
<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>
|
||||
|
||||
@@ -51,7 +51,8 @@ import {
|
||||
playerYouTubeJsFallback,
|
||||
playerYouTubeJsAlways,
|
||||
interfaceSearchHistoryEnabled,
|
||||
playerPreferredVolumeStore
|
||||
playerPreferredVolumeStore,
|
||||
watchHistoryEnabledStore
|
||||
} from '$lib/store';
|
||||
import { isOwnBackend } from '$lib/shared';
|
||||
|
||||
@@ -338,6 +339,11 @@ if (isOwnBackend()) {
|
||||
store: playerYouTubeJsAlways,
|
||||
schema: zBoolean
|
||||
});
|
||||
persistedStores.push({
|
||||
name: 'watchHistoryEnabled',
|
||||
store: watchHistoryEnabledStore,
|
||||
schema: zBoolean
|
||||
});
|
||||
}
|
||||
|
||||
export const persistedStoreKeys = persistedStores.map((store) => store.name);
|
||||
|
||||
@@ -187,6 +187,7 @@
|
||||
"companionUrl": "Companion URL",
|
||||
"deleteAccount": "Delete account",
|
||||
"clickXmoreTimesToDelete": "Click {{clicksTillDelete}} more time(s) to delete",
|
||||
"historyEnabled": "Save watch history",
|
||||
"theme": {
|
||||
"theme": "Theme",
|
||||
"darkMode": "Dark mode",
|
||||
|
||||
@@ -329,6 +329,12 @@ export const rawMasterKeyStore: Writable<string | undefined> = persist(
|
||||
'rawMasterKey'
|
||||
);
|
||||
|
||||
export const watchHistoryEnabledStore: Writable<boolean> = persist(
|
||||
writable(true),
|
||||
createStorage(),
|
||||
'watchHistoryEnabled'
|
||||
);
|
||||
|
||||
export const syncPartyPeerStore: Writable<Peer | null> = writable(null);
|
||||
export const syncPartyConnectionsStore: Writable<DataConnection[] | null> = writable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user