Remove trending page
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "Materialious",
|
||||
"version": "1.11.5",
|
||||
"version": "1.11.6",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "Materialious",
|
||||
"version": "1.11.5",
|
||||
"version": "1.11.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@capacitor-community/electron": "^5.0.0",
|
||||
|
||||
@@ -68,11 +68,6 @@ export function buildAuthHeaders(): { headers: Record<string, string> } {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTrending(fetchOptions?: RequestInit): Promise<Video[]> {
|
||||
const resp = await fetchErrorHandle(await fetch(setRegion(buildPath('trending')), fetchOptions));
|
||||
return await resp.json();
|
||||
}
|
||||
|
||||
export async function getPopular(fetchOptions?: RequestInit): Promise<Video[]> {
|
||||
const resp = await fetchErrorHandle(await fetch(buildPath('popular'), fetchOptions));
|
||||
return await resp.json();
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
let resp;
|
||||
try {
|
||||
resp = await fetch(`${instance}/api/v1/trending`);
|
||||
resp = await fetch(`${instance}/api/v1/channels/UCH-_hzb2ILSCo9ftVSnrCIQ`);
|
||||
} catch {
|
||||
invalidInstance = true;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,6 @@ export function getPages(): Pages {
|
||||
name: get(_)('pages.home'),
|
||||
requiresAuth: false
|
||||
},
|
||||
{
|
||||
icon: 'whatshot',
|
||||
href: '/trending',
|
||||
name: get(_)('pages.trending'),
|
||||
requiresAuth: false
|
||||
},
|
||||
{
|
||||
icon: 'subscriptions',
|
||||
href: '/subscriptions',
|
||||
@@ -30,13 +24,5 @@ export function getPages(): Pages {
|
||||
name: get(_)('pages.playlists'),
|
||||
requiresAuth: true
|
||||
}
|
||||
// Temporarily disable history page due to limitations with
|
||||
// Invidious's API
|
||||
// {
|
||||
// icon: 'history',
|
||||
// href: '/history',
|
||||
// name: get(_)('pages.history'),
|
||||
// requiresAuth: true
|
||||
// }
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { deleteAllVideoProgress, deleteHistory, getHistory, getVideo } from '$lib/api';
|
||||
import type { VideoPlay } from '$lib/api/model';
|
||||
import PageLoading from '$lib/components/PageLoading.svelte';
|
||||
import { synciousStore } from '$lib/store';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { onMount } from 'svelte';
|
||||
import { _ } from '$lib/i18n';
|
||||
import InfiniteLoading, { type InfiniteEvent } from 'svelte-infinite-loading';
|
||||
import { get } from 'svelte/store';
|
||||
import ItemsList from '$lib/components/ItemsList.svelte';
|
||||
|
||||
let history: VideoPlay[] = $state([]);
|
||||
let loaded = $state(false);
|
||||
|
||||
let currentPage = 1;
|
||||
|
||||
async function loadPageHistory() {
|
||||
try {
|
||||
const videoIds = await getHistory(currentPage, 20);
|
||||
let promises = [];
|
||||
for (const videoId of videoIds) {
|
||||
promises.push(
|
||||
getVideo(videoId).catch(() => {
|
||||
return null;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
const loadedHistory = (await Promise.all(promises)).filter((item) => {
|
||||
return item !== null;
|
||||
}) as VideoPlay[];
|
||||
history = [...history, ...loadedHistory];
|
||||
} catch (errorMessage: any) {
|
||||
error(500, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMore(event: InfiniteEvent) {
|
||||
const pastHistoryLen = Number(history.length);
|
||||
|
||||
currentPage++;
|
||||
|
||||
await loadPageHistory();
|
||||
|
||||
if (pastHistoryLen === history.length) {
|
||||
event.detail.complete();
|
||||
} else {
|
||||
event.detail.loaded();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await loadPageHistory();
|
||||
loaded = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="space"></div>
|
||||
<nav class="right-align">
|
||||
<button
|
||||
onclick={async () => {
|
||||
await deleteHistory();
|
||||
|
||||
if (get(synciousStore)) {
|
||||
deleteAllVideoProgress();
|
||||
}
|
||||
|
||||
history = [];
|
||||
try {
|
||||
Object.keys(localStorage).forEach((key) => {
|
||||
if (key.startsWith('v_')) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
});
|
||||
} catch {}
|
||||
}}
|
||||
>
|
||||
<i>delete_sweep</i>
|
||||
<span>{$_('deleteAllHistory')}</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
{#if loaded}
|
||||
<ItemsList items={history} />
|
||||
|
||||
<InfiniteLoading on:infinite={loadMore} />
|
||||
{:else}
|
||||
<PageLoading />
|
||||
{/if}
|
||||
@@ -1,6 +0,0 @@
|
||||
<script lang="ts">
|
||||
import ItemsList from '$lib/components/ItemsList.svelte';
|
||||
import { feedCacheStore } from '$lib/store';
|
||||
</script>
|
||||
|
||||
<ItemsList items={$feedCacheStore.trending ?? []} />
|
||||
@@ -1,22 +0,0 @@
|
||||
import { getTrending } from '$lib/api/index';
|
||||
import { feedCacheStore } from '$lib/store';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export async function load() {
|
||||
let trending = get(feedCacheStore).trending;
|
||||
|
||||
if (!trending) {
|
||||
try {
|
||||
trending = await getTrending();
|
||||
} catch (errorMessage: any) {
|
||||
error(500, errorMessage);
|
||||
}
|
||||
|
||||
feedCacheStore.set({ ...get(feedCacheStore), trending });
|
||||
} else {
|
||||
getTrending().then((newTrending) =>
|
||||
feedCacheStore.set({ ...get(feedCacheStore), trending: newTrending })
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user