Custimise cull amount
This commit is contained in:
@@ -2,8 +2,10 @@ import { localDb } from '$lib/dexie';
|
||||
import { logoutStores } from '$lib/misc';
|
||||
import { cleanNumber } from '$lib/numbers';
|
||||
import { relativeTimestamp } from '$lib/time';
|
||||
import { get } from 'svelte/store';
|
||||
import type { Feed, Subscription, Thumbnail, Video } from '../model';
|
||||
import { getChannelYTjs } from './channel';
|
||||
import { engineCullYTStore } from '$lib/store';
|
||||
|
||||
export async function getSubscriptionsYTjs(): Promise<Subscription[]> {
|
||||
const subscriptions: Subscription[] = [];
|
||||
@@ -150,9 +152,10 @@ export async function getFeedYTjs(maxResults: number, page: number): Promise<Fee
|
||||
const videos = await localDb.subscriptionFeed.toArray();
|
||||
videos.sort((a, b) => b.published - a.published);
|
||||
|
||||
// Cull videos if there are more than 1000
|
||||
if (videos.length > 1000) {
|
||||
const videosToDelete = videos.slice(1000);
|
||||
const cullAfter = get(engineCullYTStore);
|
||||
|
||||
if (videos.length > cullAfter) {
|
||||
const videosToDelete = videos.slice(cullAfter);
|
||||
const videoIdsToDelete = videosToDelete.map((video) => video.videoId);
|
||||
|
||||
await localDb.subscriptionFeed.where('id').anyOf(videoIdsToDelete).delete();
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { isYTBackend } from '$lib/misc';
|
||||
import { _ } from '$lib/i18n';
|
||||
import { engineCullYTStore } from '$lib/store';
|
||||
</script>
|
||||
|
||||
{#if isYTBackend()}
|
||||
<div class="field label prefix border">
|
||||
<i>view_stream</i>
|
||||
<input
|
||||
oninput={(event: Event) => {
|
||||
engineCullYTStore.set(Number((event.target as HTMLInputElement).value));
|
||||
}}
|
||||
value={$engineCullYTStore}
|
||||
name="cull"
|
||||
type="number"
|
||||
/>
|
||||
<label for="cull">{$_('layout.backendEngine.cull')}</label>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, type Component } from 'svelte';
|
||||
import { _ } from '$lib/i18n';
|
||||
import ApiExtended from './ApiExtended.svelte';
|
||||
import DeArrow from './DeArrow.svelte';
|
||||
@@ -7,13 +7,15 @@
|
||||
import Player from './Player.svelte';
|
||||
import Ryd from './RYD.svelte';
|
||||
import SponsorBlock from './SponsorBlock.svelte';
|
||||
import { instanceStore, isAndroidTvStore } from '$lib/store';
|
||||
import { isAndroidTvStore } from '$lib/store';
|
||||
import About from './About.svelte';
|
||||
import Engine from './Engine.svelte';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
let activeTab = $state('interface');
|
||||
const isActive = (id: string) => activeTab === id;
|
||||
|
||||
const tabs = [
|
||||
const tabs: { id: string; label: string; icon: string; component: Component }[] = [
|
||||
{ id: 'interface', label: $_('layout.interface'), icon: 'grid_view', component: Interface },
|
||||
{ id: 'player', label: $_('layout.player.title'), icon: 'smart_display', component: Player },
|
||||
{ id: 'ryd', label: 'RYD', icon: 'thumb_down', component: Ryd },
|
||||
@@ -33,6 +35,15 @@
|
||||
}
|
||||
];
|
||||
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
tabs.splice(1, 0, {
|
||||
id: 'engine',
|
||||
label: $_('layout.engine'),
|
||||
icon: 'build',
|
||||
component: Engine
|
||||
});
|
||||
}
|
||||
|
||||
const tabIds = tabs.map((tab) => tab.id);
|
||||
|
||||
let dialogType = $state('');
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
"layout": {
|
||||
"interface": "Interface",
|
||||
"star": "Star us on Github!",
|
||||
"engine": "Backend engine",
|
||||
"syncParty": "Sync party",
|
||||
"about": "About",
|
||||
"syncPartyWarning": "Please note your IP will be visible to users you invite.",
|
||||
@@ -174,6 +175,9 @@
|
||||
"allowInsecureRequests": "Allow insecure requests",
|
||||
"disableAutoUpdate": "Disable automatic updates",
|
||||
"androidNativeShare": "Use native share",
|
||||
"backendEngine": {
|
||||
"cull": "Max feed items"
|
||||
},
|
||||
"player": {
|
||||
"title": "Player",
|
||||
"autoPlay": "Autoplay video",
|
||||
|
||||
@@ -12,13 +12,8 @@ import {
|
||||
import type { TitleCase } from './letterCasing';
|
||||
import { serialize, deserialize } from '@macfja/serializer';
|
||||
import type {
|
||||
Channel,
|
||||
ChannelContent,
|
||||
ChannelContentPlaylists,
|
||||
ChannelContentVideos,
|
||||
ChannelPage,
|
||||
HashTag,
|
||||
Playlist,
|
||||
PlaylistPage,
|
||||
PlaylistPageVideo,
|
||||
SearchResults,
|
||||
@@ -318,6 +313,12 @@ export const deArrowThumbnailInstanceStore = persist(
|
||||
'deArrowThumbnailInstance'
|
||||
);
|
||||
|
||||
export const engineCullYTStore: Writable<number> = persist(
|
||||
writable(1000),
|
||||
createStorage(),
|
||||
'engineCullYT'
|
||||
);
|
||||
|
||||
export const syncPartyPeerStore: Writable<Peer | null> = writable(null);
|
||||
export const syncPartyConnectionsStore: Writable<DataConnection[] | null> = writable();
|
||||
|
||||
|
||||
@@ -14,8 +14,12 @@
|
||||
let playlistPrivacy: 'public' | 'private' | 'unlisted' = 'public';
|
||||
let playlistTitle: string = $state('');
|
||||
|
||||
function onPrivacyChange(event: any) {
|
||||
playlistPrivacy = event.currentTarget.value;
|
||||
function onPrivacyChange(event: Event) {
|
||||
if (!event.currentTarget) return;
|
||||
playlistPrivacy = (event.currentTarget as HTMLInputElement).value as
|
||||
| 'public'
|
||||
| 'private'
|
||||
| 'unlisted';
|
||||
}
|
||||
|
||||
async function removePlaylistItem(playlistId: string) {
|
||||
|
||||
Reference in New Issue
Block a user