Fix to timing issue android persist stores

This commit is contained in:
WardPearce
2026-01-02 20:31:54 +13:00
parent e6e8e99d5f
commit 63b866cecb
2 changed files with 19 additions and 1 deletions
@@ -967,6 +967,7 @@
// Force android to tap an addtional time.
if (Capacitor.getPlatform() === 'android' && androidFirstTap) {
clickCount = 0;
androidFirstTap = false;
return;
}
+18 -1
View File
@@ -6,9 +6,12 @@ import { getResolveUrl } from '$lib/api';
import '$lib/i18n'; // Import to initialize. Important :)
import { initI18n } from '$lib/i18n';
import { getPages } from '$lib/navPages';
import { authStore, interfaceDefaultPage, isAndroidTvStore } from '$lib/store';
import { authStore, instanceStore, interfaceDefaultPage, isAndroidTvStore } from '$lib/store';
import { get } from 'svelte/store';
import '$lib/android/http/androidRequests';
import { Capacitor } from '@capacitor/core';
import { Preferences } from '@capacitor/preferences';
import { deserialize } from '@macfja/serializer';
export const ssr = false;
@@ -19,6 +22,20 @@ export async function load({ url }) {
isAndroidTvStore.set((await androidTv.isAndroidTv()).value);
// Due to race condition with how we set & save persistent store values
// we manually set stores like auth & instance before load.
if (Capacitor.getPlatform() === 'android') {
const instancePreferences = await Preferences.get({ key: 'invidiousInstance' });
if (instancePreferences.value !== null) {
instanceStore.set(deserialize(instancePreferences.value));
}
const authPreferences = await Preferences.get({ key: 'authToken' });
if (authPreferences.value !== null) {
authStore.set(deserialize(authPreferences.value));
}
}
const resolvedRoot = resolve('/', {});
if (url.pathname.startsWith(resolvedRoot + '@')) {
const username = url.pathname.substring(resolvedRoot.length).split('/')[0];