diff --git a/README.md b/README.md index 4257ddf0..e7abd44b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Modern material design for Invidious - Custom colour themes. - Integrates with Invidious subscriptions, watch history & more. - Live stream support. -- Dash support (WIP). +- Dash support. - Chapters. - Audio only mode. @@ -23,7 +23,6 @@ Modern material design for Invidious - Complete channel view. - Add different search filters. - Playlist support. -- History deletion. - PWA support. ## Previews diff --git a/materialious/src/lib/Api/index.ts b/materialious/src/lib/Api/index.ts index cdd58c56..eab45ffe 100644 --- a/materialious/src/lib/Api/index.ts +++ b/materialious/src/lib/Api/index.ts @@ -124,6 +124,18 @@ export async function getHistory(page: number = 1): Promise { return await resp.json(); } +export async function deleteHistory(videoId: string | undefined = undefined) { + let url = '/api/v1/auth/history'; + if (typeof videoId !== 'undefined') { + url += `/${videoId}`; + } + + await fetch(buildPath(url), { + method: 'DELETE', + ...buildAuthHeaders() + }); +} + export async function postHistory(videoId: string) { await fetch(buildPath(`auth/history/${videoId}`), { method: 'POST', diff --git a/materialious/src/lib/Player.svelte b/materialious/src/lib/Player.svelte index 011bcfbb..584c34a0 100644 --- a/materialious/src/lib/Player.svelte +++ b/materialious/src/lib/Player.svelte @@ -162,6 +162,10 @@ }); +{#if audioMode} +
+{/if} + - import { getHistory, getVideo } from '$lib/Api'; + import { deleteHistory, getHistory, getVideo } from '$lib/Api'; import type { VideoPlay } from '$lib/Api/model'; import VideoList from '$lib/VideoList.svelte'; import { onDestroy, onMount } from 'svelte'; @@ -19,7 +19,9 @@ promises.push(getVideo(videoId)); } - const loadedHistory = await Promise.all(promises); + const loadedHistory = (await Promise.all(promises)).sort((a: VideoPlay, b: VideoPlay) => { + return a.published > b.published ? -1 : 1; + }); history = [...history, ...loadedHistory]; } @@ -43,4 +45,16 @@ }); +
+ +
+