From 056c25a0352d5017a546a0ca8e6913e20300e530 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Mon, 9 Mar 2026 21:29:00 +1300 Subject: [PATCH] Added more methods of history --- materialious/src/lib/api/backend/history.ts | 10 +++++++ materialious/src/lib/api/index.ts | 9 +++++++ .../lib/components/layout/ItemsList.svelte | 27 ++----------------- .../routes/(app)/playlist/[slug]/+page.svelte | 6 +---- 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/materialious/src/lib/api/backend/history.ts b/materialious/src/lib/api/backend/history.ts index 951aeb17..2bdf6566 100644 --- a/materialious/src/lib/api/backend/history.ts +++ b/materialious/src/lib/api/backend/history.ts @@ -118,6 +118,16 @@ export async function deleteWatchHistoryBackend() { await fetch('/api/user/history', { method: 'DELETE' }); } +export async function deleteWatchHistoryItemBackend(videoId: string) { + await sodium.ready; + const rawKey = await getRawKey(); + if (!rawKey) return; + + const videoHash = await getSecureHash(videoId, rawKey); + + await fetch(`/api/user/history/${videoHash}`, { method: 'DELETE' }); +} + export async function saveWatchHistoryBackend(video: VideoPlay, progress: number = 0) { await sodium.ready; const rawKey = await getRawKey(); diff --git a/materialious/src/lib/api/index.ts b/materialious/src/lib/api/index.ts index 2d4565e0..6039278c 100644 --- a/materialious/src/lib/api/index.ts +++ b/materialious/src/lib/api/index.ts @@ -74,6 +74,7 @@ import { } from './invidious/playlist'; import { deleteWatchHistoryBackend, + deleteWatchHistoryItemBackend, getVideoWatchHistoryBackend, getWatchHistoryBackend, saveWatchHistoryBackend, @@ -343,6 +344,14 @@ export async function deleteWatchHistory() { await localDb.watchHistory.clear(); } +export async function deleteWatchHistoryItem(videoId: string) { + if (isOwnBackend()?.internalAuth && get(rawMasterKeyStore)) { + return deleteWatchHistoryItemBackend(videoId); + } + + await localDb.watchHistory.delete({ videoId }); +} + export async function updateWatchHistory( videoId: string, progress: number, diff --git a/materialious/src/lib/components/layout/ItemsList.svelte b/materialious/src/lib/components/layout/ItemsList.svelte index d62b6af6..5c91357b 100644 --- a/materialious/src/lib/components/layout/ItemsList.svelte +++ b/materialious/src/lib/components/layout/ItemsList.svelte @@ -1,7 +1,6 @@