Improve android fetch
This commit is contained in:
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "us.materialio.app"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 154
|
||||
versionName "1.10.13"
|
||||
versionCode 155
|
||||
versionName "1.10.14"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -71,7 +71,11 @@
|
||||
|
||||
|
||||
|
||||
<release version="1.10.13" date="2025-10-08">
|
||||
|
||||
<release version="1.10.14" date="2025-10-08">
|
||||
<url>https://github.com/Materialious/Materialious/releases/tag/1.10.14</url>
|
||||
</release>
|
||||
<release version="1.10.13" date="2025-10-08">
|
||||
<url>https://github.com/Materialious/Materialious/releases/tag/1.10.13</url>
|
||||
</release>
|
||||
<release version="1.10.12" date="2025-10-07">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Materialious",
|
||||
"version": "1.10.13",
|
||||
"version": "1.10.14",
|
||||
"description": "Modern material design for Invidious.",
|
||||
"author": {
|
||||
"name": "Ward Pearce",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "materialious",
|
||||
"version": "1.10.13",
|
||||
"version": "1.10.14",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { isAndroidTvStore } from '$lib/store';
|
||||
import { timeout } from '$lib/misc';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { NodeJS } from 'capacitor-nodejs';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
const originalFetch = window.fetch;
|
||||
const corsProxyUrl: string = 'http://localhost:3000/';
|
||||
|
||||
let nodejsStarted = false;
|
||||
|
||||
function needsProxying(target: string): boolean {
|
||||
if (!target.startsWith('http')) return false;
|
||||
return true;
|
||||
@@ -16,6 +16,19 @@ export const androidFetch = async (
|
||||
requestInput: string | URL | Request,
|
||||
requestOptions?: RequestInit
|
||||
): Promise<Response> => {
|
||||
// On initial request pause until OPTIONS request passes on local proxy, only reliable way
|
||||
// to ensure proxy is working on android.
|
||||
if (!nodejsStarted) {
|
||||
let testResp: Response | undefined = undefined;
|
||||
while (typeof testResp === 'undefined' || !testResp.ok) {
|
||||
try {
|
||||
testResp = await originalFetch(corsProxyUrl, { method: 'OPTIONS' });
|
||||
} catch (error) {}
|
||||
await timeout(100);
|
||||
}
|
||||
nodejsStarted = true;
|
||||
}
|
||||
|
||||
const uri = requestInput instanceof Request ? requestInput.url : requestInput.toString();
|
||||
|
||||
if (needsProxying(uri)) {
|
||||
@@ -54,17 +67,4 @@ if (Capacitor.getPlatform() === 'android') {
|
||||
/* @ts-ignore */
|
||||
return originalXhrOpen.apply(this, args);
|
||||
};
|
||||
|
||||
NodeJS.whenReady().then(() => {
|
||||
goto('/', { replaceState: true });
|
||||
});
|
||||
|
||||
// Required for Android TV to load correctly.
|
||||
let hasReloaded = false;
|
||||
isAndroidTvStore.subscribe((isAndroidTv) => {
|
||||
if (hasReloaded || !isAndroidTv) return;
|
||||
hasReloaded = true;
|
||||
|
||||
setTimeout(() => goto('/', { replaceState: true }), 2000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,12 +16,6 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>
|
||||
Materialious is a modern material design frontend for Invidious, focused on a clean,
|
||||
privacy-friendly YouTube experience. It supports local video fallback when Invidious fails and is
|
||||
available on Web, Desktop, Android, and Android TV.
|
||||
</p>
|
||||
|
||||
<div class="grid">
|
||||
<div class="s12 m4 l4">
|
||||
<a href="https://github.com/sponsors/WardPearce" target="_blank" referrerpolicy="no-referrer">
|
||||
|
||||
@@ -140,3 +140,7 @@ export function createVideoUrl(videoId: string, playlistId: string): URL {
|
||||
|
||||
return watchUrl;
|
||||
}
|
||||
|
||||
export function timeout(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
LATEST_VERSION = "1.10.13"
|
||||
LATEST_VERSION = "1.10.14"
|
||||
RELEASE_DATE = datetime.now().strftime("%Y-%-m-%d") # Format: YYYY-M-D
|
||||
|
||||
WORKING_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "materialious")
|
||||
|
||||
Reference in New Issue
Block a user