fix reloads

This commit is contained in:
cutestnekoaqua 2023-04-08 14:31:41 +02:00
parent 2464223073
commit 9e86d5dde7
No known key found for this signature in database
GPG Key ID: 6BF0964A5069C1E0
5 changed files with 16 additions and 5 deletions

View File

@ -34,6 +34,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation 'com.jakewharton:process-phoenix:2.1.2'
implementation project(':capacitor-android') implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion" testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"

View File

@ -6,6 +6,7 @@ import android.webkit.WebSettings;
import com.getcapacitor.BridgeActivity; import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin; import com.getcapacitor.Plugin;
import com.jakewharton.processphoenix.ProcessPhoenix;
import java.util.ArrayList; import java.util.ArrayList;
@ -30,6 +31,10 @@ public class MainActivity extends BridgeActivity {
} }
} }
public void restartApp() {
ProcessPhoenix.triggerRebirth(this.getApplicationContext());
}
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();

View File

@ -16,6 +16,7 @@ const res = await Device.getInfo();
storedDeviceInfo = res; storedDeviceInfo = res;
if (!localStorage.getItem("lang")) { if (!localStorage.getItem("lang")) {
localStorage.setItem("lang", "en-US"); localStorage.setItem("lang", "en-US");
document.location.href = '/';
} }
const lang: string = localStorage.getItem("lang") || ""; const lang: string = localStorage.getItem("lang") || "";
const lang_res = await fetch(`/assets/locales/${lang}.${version}.json`); const lang_res = await fetch(`/assets/locales/${lang}.${version}.json`);
@ -229,7 +230,11 @@ const onesignal_app_id = "efe09597-0778-4156-97b7-0bf8f52c21a7";
console.log("not signed in"); console.log("not signed in");
} }
// #v-ifdef VITE_CAPACITOR // #v-ifdef VITE_CAPACITOR
applyTheme(lightThemeDefault); applyTheme(
defaultStore.reactiveState.darkMode.value ?
ColdDeviceStorage.get("darkTheme") :
ColdDeviceStorage.get("lightTheme")
)
// #v-endif // #v-endif
} }
} }

View File

@ -219,9 +219,9 @@ async function reloadAsk() {
function unisonReload(path?: string) { function unisonReload(path?: string) {
if (path !== undefined) { if (path !== undefined) {
location.href = path; document.location.href = path;
} else { } else {
location.reload(); document.location.reload();
} }
} }
// #v-endif // #v-endif

View File

@ -7,9 +7,9 @@ export const reloadChannel = new BroadcastChannel<string | null>("reload");
export function unisonReload(path?: string) { export function unisonReload(path?: string) {
if (path !== undefined) { if (path !== undefined) {
reloadChannel.postMessage(path); reloadChannel.postMessage(path);
location.href = path; document.location.href = path;
} else { } else {
reloadChannel.postMessage(null); reloadChannel.postMessage(null);
location.reload(); document.location.reload();
} }
} }