Minor fixes

This commit is contained in:
WardPearce
2024-09-07 17:01:21 +12:00
parent 618130afe5
commit e71c8280f6
4 changed files with 32 additions and 12 deletions
+2
View File
@@ -175,6 +175,8 @@ export async function getSubscriptions(): Promise<Subscription[]> {
}
export async function amSubscribed(authorId: string): Promise<boolean> {
if (!get(authStore)) return false;
try {
const subscriptions = (await getSubscriptions()).filter((sub) => sub.authorId === authorId);
return subscriptions.length === 1;
+14 -8
View File
@@ -4,6 +4,7 @@
import { page } from '$app/stores';
import { Capacitor } from '@capacitor/core';
import type { Page } from '@sveltejs/kit';
import { type ParsedCaptionsResult } from 'media-captions';
import { SponsorBlock, type Category } from 'sponsorblock-api';
import { onDestroy, onMount } from 'svelte';
import { _ } from 'svelte-i18n';
@@ -26,6 +27,7 @@
sponsorBlockDisplayToastStore,
sponsorBlockStore,
sponsorBlockUrlStore,
synciousInstanceStore,
synciousStore
} from './store';
import { getDynamicTheme } from './theme';
@@ -41,6 +43,8 @@
let playerIsLive = false;
let playerPosSet = false;
let transcript: ParsedCaptionsResult;
function loadTimeFromUrl(page: Page): boolean {
if (player) {
const timeGivenUrl = page.url.searchParams.get('time');
@@ -90,11 +94,13 @@
timestampIndex += 1;
});
player.textTracks.add({
kind: 'chapters',
src: URL.createObjectURL(new Blob([chapterWebVTT])),
default: true
});
if (timestampIndex > 0) {
player.textTracks.add({
kind: 'chapters',
src: URL.createObjectURL(new Blob([chapterWebVTT])),
default: true
});
}
}
player.addEventListener('pause', () => {
@@ -217,7 +223,7 @@
let toSetTime = 0;
if (get(synciousStore) && get(authStore)) {
if (get(synciousStore) && get(synciousInstanceStore) && get(authStore)) {
try {
toSetTime = (await getVideoProgress(data.video.videoId))[0].time;
} catch {}
@@ -244,7 +250,7 @@
localStorage.setItem(`v_${data.video.videoId}`, player.currentTime.toString());
} catch {}
if (get(synciousStore) && get(authStore)) {
if (get(synciousStore) && get(synciousInstanceStore) && get(authStore)) {
saveVideoProgress(data.video.videoId, player.currentTime);
}
} else {
@@ -252,7 +258,7 @@
localStorage.removeItem(`v_${data.video.videoId}`);
} catch {}
if (get(synciousStore) && get(authStore)) {
if (get(synciousStore) && get(synciousInstanceStore) && get(authStore)) {
deleteVideoProgress(data.video.videoId);
}
}
+2 -1
View File
@@ -22,6 +22,7 @@
playerSavePlaybackPositionStore,
syncPartyConnectionsStore,
syncPartyPeerStore,
synciousInstanceStore,
synciousStore
} from './store';
@@ -195,7 +196,7 @@
loading = false;
};
if (get(synciousStore) && get(authStore)) {
if (get(synciousStore) && get(synciousInstanceStore) && get(authStore)) {
try {
progress = (await getVideoProgress(video.videoId))[0].time.toString();
} catch {}
+14 -3
View File
@@ -1,13 +1,24 @@
import type { VideoPlay } from '$lib/Api/model';
import { Capacitor } from '@capacitor/core';
import type Peer from 'peerjs';
import type { DataConnection } from 'peerjs';
import { persisted } from 'svelte-persisted-store';
import { writable, type Writable } from 'svelte/store';
import type { TitleCase } from './misc';
function platformDependentDefault(givenValue: any, defaultValue: any): any {
if (typeof givenValue !== 'undefined' || typeof givenValue !== null) {
return givenValue;
} else if (defaultValue && Capacitor.getPlatform() !== 'web') {
return defaultValue;
}
}
export const instanceStore: Writable<string> = persisted(
"invidiousInstance",
import.meta.env.VITE_DEFAULT_INVIDIOUS_INSTANCE || 'https://invidious.materialio.us'
platformDependentDefault(import.meta.env.VITE_DEFAULT_INVIDIOUS_INSTANCE, 'https://invidious.materialio.us')
);
export const authStore: Writable<null | { username: string; token: string; }> = persisted(
@@ -34,13 +45,13 @@ export const playerAndroidBackgroundPlayStore = persisted('androidBackgroundPlay
export const returnYtDislikesStore = persisted('returnYtDislikes', false);
export const returnYTDislikesInstanceStore: Writable<string | null | undefined> = persisted(
'returnYTDislikesInstance',
import.meta.env.VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE || 'https://ryd-proxy.materialio.us'
platformDependentDefault(import.meta.env.VITE_DEFAULT_RETURNYTDISLIKES_INSTANCE, 'https://ryd-proxy.materialio.us')
);
export const synciousStore = persisted('syncious', true);
export const synciousInstanceStore: Writable<string | null | undefined> = persisted(
'synciousInstance',
import.meta.env.VITE_DEFAULT_SYNCIOUS_INSTANCE || 'https://syncious.materialio.us'
platformDependentDefault(import.meta.env.VITE_DEFAULT_SYNCIOUS_INSTANCE, 'https://syncious.materialio.us')
);
export const interfaceRegionStore: Writable<string> = persisted('interfaceRegion', 'US');