Companion improvements

This commit is contained in:
WardPearce
2025-06-05 13:48:16 +12:00
parent 7d7d79db9d
commit 0344883d67
4 changed files with 13 additions and 44 deletions
@@ -23,7 +23,6 @@
import type { VideoPlay } from '../api/model';
import {
authStore,
companionStore,
instanceStore,
playerAndroidLockOrientation,
playerAutoPlayStore,
@@ -318,10 +317,6 @@
(button as HTMLElement).blur(); // Remove focus from the button
button.removeAttribute('aria-pressed'); // Reset any ARIA attributes that might indicate selection
});
const tempDiv = document.createElement('div');
tempDiv.click();
document.removeChild(tempDiv);
});
// Based off the following
@@ -629,10 +624,16 @@
await player.attach(playerElement);
if (!data.video.hlsUrl) {
console.log(data.video.dashUrl);
if (!data.video.liveNow) {
let dashUrl: string = '';
if ($companionStore) {
dashUrl = `${$companionStore}/api/manifest/dash/id/${data.video.videoId}`;
// Due to CORs issues with redirects, hosted instances of Materialious
// dirctly provide the companion instance
// while clients can just use the reirect provided by Invidious' API
if (import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE && Capacitor.getPlatform() === 'web') {
dashUrl = `${import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE}/api/manifest/dash/id/${data.video.videoId}`;
} else {
dashUrl = data.video.dashUrl;
}
@@ -13,7 +13,6 @@
import { getPages } from '../../navPages';
import {
authStore,
companionStore,
darkModeStore,
instanceStore,
interfaceAllowInsecureRequests,
@@ -31,7 +30,6 @@
} from '../../store';
let invidiousInstance = $state(get(instanceStore));
let companionInstance = $state(get(companionStore));
let region = $state(get(interfaceRegionStore));
let forceCase = $state(get(interfaceForceCase));
let defaultPage = $state(get(interfaceDefaultPage));
@@ -93,11 +91,6 @@
ui('#dialog-settings');
}
function setCompanion(event: Event) {
event.preventDefault();
companionStore.set(ensureNoTrailingSlash(companionInstance));
}
function allowInsecureRequests() {
if (!Capacitor.isNativePlatform()) return;
interfaceAllowInsecureRequests.set(!$interfaceAllowInsecureRequests);
@@ -153,21 +146,6 @@
</nav>
</div>
{/if}
<form onsubmit={setCompanion}>
<nav>
<div class="field label border max">
<input bind:value={companionInstance} name="companion-instance" type="text" />
<label for="companion-instance">{$_('layout.companionUrl')}</label>
</div>
<button class="square round">
<i>done</i>
</button>
</nav>
</form>
{#if invalidInstance}
<div style="margin-bottom: 6em;"></div>
{/if}
{/if}
<button onclick={toggleDarkMode} class="no-margin">
@@ -53,10 +53,6 @@
<i>smart_display</i>
<span>{$_('layout.player.title')}</span>
</a>
<a class:active={activeTab === 'data'} onclick={() => (activeTab = 'data')}>
<i>save</i>
<span>{$_('layout.dataPreferences.dataPreferences')}</span>
</a>
<a class:active={activeTab === 'ryd'} onclick={() => (activeTab = 'ryd')}>
<i>thumb_down</i>
<span>RYD</span>
@@ -73,6 +69,10 @@
<i>keyboard_double_arrow_down</i>
<span>{$_('layout.deArrow.title')}</span>
</a>
<a class:active={activeTab === 'data'} onclick={() => (activeTab = 'data')}>
<i>save</i>
<span>{$_('layout.dataPreferences.dataPreferences')}</span>
</a>
<a href="https://github.com/sponsors/WardPearce" target="_blank" referrerpolicy="no-referrer">
<i>favorite</i>
<span>{$_('donate')}</span>
-10
View File
@@ -25,16 +25,6 @@ export const instanceStore: Writable<string> = persisted(
)
);
export const companionStore: Writable<string | undefined> = persisted(
'companionInstance',
platformDependentDefault(
!import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE
? undefined
: ensureNoTrailingSlash(import.meta.env.VITE_DEFAULT_COMPANION_INSTANCE),
undefined
)
);
export const authStore: Writable<null | { username: string; token: string }> = persisted(
'authToken',
null