mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
If Equicord Fails To Initialize Reload
This works for me but needs more testing
This commit is contained in:
parent
0e856059d8
commit
f527df76b8
2 changed files with 52 additions and 9 deletions
|
@ -30,6 +30,7 @@ import "./utils/quickCss";
|
||||||
import "./webpack/patchWebpack";
|
import "./webpack/patchWebpack";
|
||||||
|
|
||||||
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
|
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
import { StartAt } from "@utils/types";
|
import { StartAt } from "@utils/types";
|
||||||
|
|
||||||
import { get as dsGet } from "./api/DataStore";
|
import { get as dsGet } from "./api/DataStore";
|
||||||
|
@ -48,6 +49,37 @@ if (IS_REPORTER) {
|
||||||
Settings.plugins.CharacterCounter.enabled = false;
|
Settings.plugins.CharacterCounter.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logger = new Logger("Debug", "#a6d189");
|
||||||
|
|
||||||
|
let isFrozen = true;
|
||||||
|
const checkInterval = 5000;
|
||||||
|
const freezeChecker = setInterval(() => {
|
||||||
|
if (isFrozen) {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
isFrozen = true;
|
||||||
|
}, checkInterval);
|
||||||
|
|
||||||
|
function safeInit() {
|
||||||
|
try {
|
||||||
|
startAllPlugins(StartAt.Init);
|
||||||
|
init();
|
||||||
|
|
||||||
|
const originalLoggerInfo = logger.info.bind(logger);
|
||||||
|
logger.info = function (message) {
|
||||||
|
originalLoggerInfo(message);
|
||||||
|
if (message.includes("Completed Equicord initialization.")) {
|
||||||
|
isFrozen = false;
|
||||||
|
clearInterval(freezeChecker);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Failed to initialize Equicord, reloading in 5 seconds...", error);
|
||||||
|
clearInterval(freezeChecker);
|
||||||
|
setTimeout(() => location.reload(), 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function syncSettings() {
|
async function syncSettings() {
|
||||||
// pre-check for local shared settings
|
// pre-check for local shared settings
|
||||||
if (
|
if (
|
||||||
|
@ -94,6 +126,8 @@ async function init() {
|
||||||
|
|
||||||
syncSettings();
|
syncSettings();
|
||||||
|
|
||||||
|
logger.info("Completed Equicord initialization.");
|
||||||
|
|
||||||
if (!IS_WEB && !IS_UPDATER_DISABLED) {
|
if (!IS_WEB && !IS_UPDATER_DISABLED) {
|
||||||
try {
|
try {
|
||||||
const isOutdated = await checkForUpdates();
|
const isOutdated = await checkForUpdates();
|
||||||
|
@ -139,16 +173,25 @@ async function init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startAllPlugins(StartAt.Init);
|
safeInit();
|
||||||
init();
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
startAllPlugins(StartAt.DOMContentLoaded);
|
try {
|
||||||
|
startAllPlugins(StartAt.DOMContentLoaded);
|
||||||
|
|
||||||
if (IS_DISCORD_DESKTOP && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) {
|
if (IS_DISCORD_DESKTOP && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) {
|
||||||
document.head.append(Object.assign(document.createElement("style"), {
|
document.head.append(Object.assign(document.createElement("style"), {
|
||||||
id: "vencord-native-titlebar-style",
|
id: "vencord-native-titlebar-style",
|
||||||
textContent: "[class*=titleBar]{display: none!important}"
|
textContent: "[class*=titleBar]{display: none!important}"
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
isFrozen = false;
|
||||||
|
clearInterval(freezeChecker);
|
||||||
|
logger.info("DOMContentLoaded event handled successfully.");
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error during DOMContentLoaded event, reloading in 5 seconds...", error);
|
||||||
|
clearInterval(freezeChecker);
|
||||||
|
setTimeout(() => location.reload(), 5000);
|
||||||
}
|
}
|
||||||
}, { once: true });
|
}, { once: true });
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { traceFunction } from "../debug/Tracer";
|
||||||
import { Flux } from "./common";
|
import { Flux } from "./common";
|
||||||
import { AnyModuleFactory, AnyWebpackRequire, ModuleExports, WebpackRequire } from "./wreq";
|
import { AnyModuleFactory, AnyWebpackRequire, ModuleExports, WebpackRequire } from "./wreq";
|
||||||
|
|
||||||
const logger = new Logger("Webpack");
|
export const logger = new Logger("Webpack");
|
||||||
|
|
||||||
export let _resolveReady: () => void;
|
export let _resolveReady: () => void;
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue