Reimplement Discord's Switch to fix performance (#413)

This commit is contained in:
Ven 2023-01-15 22:26:02 +01:00 committed by GitHub
parent e49151ff33
commit 1d287357ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 57 deletions

View file

@ -49,9 +49,11 @@ if (location.protocol !== "data:") {
const css = readFileSync(rendererCss, "utf-8");
insertCss(css);
if (IS_DEV) {
watch(rendererCss, debounce(() => {
// persistent means keep process running if watcher is the only thing still running
// which we obviously don't want
watch(rendererCss, { persistent: false }, () => {
document.getElementById("vencord-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
}, 30));
});
}
} catch (err) {
if ((err as NodeJS.ErrnoException)?.code !== "ENOENT")