If Equicord Fails To Initialize Reload
Some checks are pending
Sync to Codeberg / Sync Codeberg and Github (push) Waiting to run
Test / Test (push) Waiting to run

This works for me but needs more testing
This commit is contained in:
thororen1234 2025-03-16 01:27:38 -04:00
parent 0e856059d8
commit f527df76b8
No known key found for this signature in database
2 changed files with 52 additions and 9 deletions

View file

@ -30,6 +30,7 @@ import "./utils/quickCss";
import "./webpack/patchWebpack";
import { openUpdaterModal } from "@components/VencordSettings/UpdaterTab";
import { Logger } from "@utils/Logger";
import { StartAt } from "@utils/types";
import { get as dsGet } from "./api/DataStore";
@ -48,6 +49,37 @@ if (IS_REPORTER) {
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() {
// pre-check for local shared settings
if (
@ -94,6 +126,8 @@ async function init() {
syncSettings();
logger.info("Completed Equicord initialization.");
if (!IS_WEB && !IS_UPDATER_DISABLED) {
try {
const isOutdated = await checkForUpdates();
@ -139,10 +173,10 @@ async function init() {
}
}
startAllPlugins(StartAt.Init);
init();
safeInit();
document.addEventListener("DOMContentLoaded", () => {
try {
startAllPlugins(StartAt.DOMContentLoaded);
if (IS_DISCORD_DESKTOP && Settings.winNativeTitleBar && navigator.platform.toLowerCase().startsWith("win")) {
@ -151,4 +185,13 @@ document.addEventListener("DOMContentLoaded", () => {
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 });

View file

@ -26,7 +26,7 @@ import { traceFunction } from "../debug/Tracer";
import { Flux } from "./common";
import { AnyModuleFactory, AnyWebpackRequire, ModuleExports, WebpackRequire } from "./wreq";
const logger = new Logger("Webpack");
export const logger = new Logger("Webpack");
export let _resolveReady: () => void;
/**