Refactor ipc to be strongly typed and hide impl details (#1018)

This commit is contained in:
V 2023-05-02 02:50:51 +02:00 committed by GitHub
parent 6a1cb133cd
commit c62d05e1b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 158 additions and 218 deletions

View file

@ -18,7 +18,6 @@
import { addSettingsListener, Settings } from "@api/settings";
import IpcEvents from "./IpcEvents";
let style: HTMLStyleElement;
let themesStyle: HTMLStyleElement;
@ -29,8 +28,8 @@ export async function toggle(isEnabled: boolean) {
style = document.createElement("style");
style.id = "vencord-custom-css";
document.head.appendChild(style);
VencordNative.ipc.on(IpcEvents.QUICK_CSS_UPDATE, (_, css: string) => style.textContent = css);
style.textContent = await VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS);
VencordNative.quickCss.addChangeListener(css => style.textContent = css);
style.textContent = await VencordNative.quickCss.get();
}
} else
style.disabled = !isEnabled;